Expand description
The module contains a Location
trait and implementations for it.
§Example
use tabled::{
settings::{
location::Locator,
object::{Columns, Object},
Alignment, Modify, Padding,
},
assert::assert_table,
Table, Tabled,
};
#[derive(Tabled)]
struct Reading {
link: &'static str,
comment: &'static str,
}
let data = [
Reading { link: "https://www.gnu.org/software/grub/manual/multiboot/multiboot.html", comment: "todo" },
Reading { link: "https://wiki.debian.org/initramfs", comment: "todo" },
Reading { link: "http://jdebp.uk/FGA/efi-boot-process.html", comment: "todo,2" },
Reading { link: "https://wiki.debian.org/UEFI", comment: "todo,2" },
];
let mut table = Table::new(data);
table.with(Padding::zero());
table.modify(Locator::column("link"), Alignment::right());
table.modify(Locator::content("todo"), "todo,1");
table.modify(
Columns::one(1).intersect(Locator::by(|text| text.contains("todo"))),
Padding::new(4, 0, 0, 0),
);
assert_table!(
table,
"+-----------------------------------------------------------------+----------+"
"| link|comment |"
"+-----------------------------------------------------------------+----------+"
"|https://www.gnu.org/software/grub/manual/multiboot/multiboot.html| todo,1|"
"+-----------------------------------------------------------------+----------+"
"| https://wiki.debian.org/initramfs| todo,1|"
"+-----------------------------------------------------------------+----------+"
"| http://jdebp.uk/FGA/efi-boot-process.html| todo,2|"
"+-----------------------------------------------------------------+----------+"
"| https://wiki.debian.org/UEFI| todo,2|"
"+-----------------------------------------------------------------+----------+"
);
Structs§
- ByColumn
Name - The structure is an implementation of
Location
to search for a column by it’s name. A name is considered be a value in a first row. - ByCondition
- The structure is an implementation of
Location
to search for cells with a specified condition. - ByContent
- The structure is an implementation of
Location
to search for cells with a given content. - ByValue
- The structure is an implementation of
Location
to search for cells with a given content. - Locator
- An abstract factory for locations, to be used to find different things on the table.