Cell

Struct Cell 

Source
pub struct Cell {
    pub value: String,
    pub align: Align,
    pub style: Style,
}

Fields§

§value: String§align: Align§style: Style

Implementations§

Source§

impl Cell

Source

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}
Source

pub fn left_with_style<T: Display>(val: T, style: Style) -> Self

Source

pub fn right<T: Display>(val: T) -> Self

Source

pub fn right_with_style<T: Display>(val: T, style: Style) -> Self

Source

pub fn center<T: Display>(val: T) -> Self

Source

pub fn center_with_style<T: Display>(val: T, style: Style) -> Self

Trait Implementations§

Source§

impl Clone for Cell

Source§

fn clone(&self) -> Cell

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cell

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Cell

Source§

fn eq(&self, other: &Cell) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.