pub struct Cell {
pub value: String,
pub align: Align,
pub style: Style,
}Fields§
§value: String§align: Align§style: StyleImplementations§
Source§impl Cell
impl Cell
Sourcepub fn left<T: Display>(val: T) -> Self
pub fn left<T: Display>(val: T) -> Self
Examples found in repository?
examples/simple.rs (line 22)
3fn main() {
4 let mut table = Table::new(vec![
5 Border::Double.into(),
6 Column::Cells {
7 width: CellSize::Flexible,
8 },
9 Border::Double.into(),
10 Column::Cells {
11 width: CellSize::Flexible,
12 },
13 Border::Single.into(),
14 Column::Cells {
15 width: CellSize::Fixed(10),
16 },
17 Border::Double.into(),
18 ]);
19 table.append_row(Border::Double.into());
20 table.append_row(Row::Cells {
21 height: CellSize::Flexible,
22 cells: vec![Cell::left(""), Cell::left("w=*"), Cell::left("w=10")],
23 });
24 table.append_row(Border::Single.into());
25 table.append_row(Row::Cells {
26 height: CellSize::Flexible,
27 cells: vec![
28 Cell::left("h=*"),
29 Cell {
30 value: "123456789012345".into(),
31 align: Align::Left,
32 style: ansi_term::Style::new(),
33 },
34 Cell {
35 value: "123456789012345".into(),
36 align: Align::Left,
37 style: ansi_term::Style::new(),
38 },
39 ],
40 });
41 table.append_row(Border::Double.into());
42 table.append_row(Row::Cells {
43 height: CellSize::Fixed(2),
44 cells: vec![
45 Cell::left("h=2"),
46 Cell {
47 value: "Left".into(),
48 align: Align::Left,
49 style: ansi_term::Style::new()
50 .bold()
51 .fg(ansi_term::Color::RGB(245, 66, 170)),
52 },
53 Cell {
54 value: "Right".into(),
55 align: Align::Right,
56 style: ansi_term::Style::new()
57 .underline()
58 .on(ansi_term::Color::RGB(66, 206, 245)),
59 },
60 ],
61 });
62 table.append_row(Border::Single.into());
63 table.append_row(Row::Cells {
64 height: CellSize::Flexible,
65 cells: vec![
66 Cell::left("h=*"),
67 Cell {
68 value: "{padl:2, padr:1}".into(),
69 align: Align::CenterPadded { padl: 2, padr: 1 },
70 style: ansi_term::Style::new().strikethrough(),
71 },
72 Cell {
73 value: "{padr:1}あいうえお1234567890かきくけこ".into(),
74 align: Align::RightPadded { padr: 1 },
75 style: ansi_term::Style::new().fg(ansi_term::Color::RGB(221, 245, 66)),
76 },
77 ],
78 });
79 table.append_row(Border::Double.into());
80
81 print!("{}", table);
82}pub fn left_with_style<T: Display>(val: T, style: Style) -> Self
pub fn right<T: Display>(val: T) -> Self
pub fn right_with_style<T: Display>(val: T, style: Style) -> Self
pub fn center<T: Display>(val: T) -> Self
pub fn center_with_style<T: Display>(val: T, style: Style) -> Self
Trait Implementations§
impl StructuralPartialEq for Cell
Auto Trait Implementations§
impl Freeze for Cell
impl RefUnwindSafe for Cell
impl Send for Cell
impl Sync for Cell
impl Unpin for Cell
impl UnwindSafe for Cell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more