Struct text_grid::RowBuilder

source ·
pub struct RowBuilder<'a> { /* private fields */ }
Expand description

A builder used to create row of GridBuilder.

This structure is created by GridBuilder::push.

Implementations§

source§

impl RowBuilder<'_>

source

pub fn push(&mut self, cell: impl CellSource)

Append a cell to the right of row.

Examples found in repository?
examples/grid_buf.rs (line 5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn main() {
    use text_grid::*;
    let mut g = GridBuilder::new();
    g.push(|b| {
        b.push(cell("name").right());
        b.push("type");
        b.push("value");
    });
    g.push_separator();
    g.push(|b| {
        b.push(cell(String::from("X")).right());
        b.push("A");
        b.push(10);
    });
    g.push(|b| {
        b.push(cell("Y").right());
        b.push_with_colspan(cell("BBB").center(), 2);
    });
    print!("{}", g);
}
More examples
Hide additional examples
examples/set_column_separators.rs (line 5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    use text_grid::*;
    let mut g = GridBuilder::new();
    g.push(|b| {
        b.push("A");
        b.push("B");
        b.push("C");
    });
    g.push(|b| {
        b.push("AAA");
        b.push("BBB");
        b.push("CCC");
    });
    g.set_column_separators(vec![true, true]);
    println!("{:?}", vec![true, true]);
    println!("{}", g);

    g.set_column_separators(vec![false, true]);
    println!("{:?}", vec![false, true]);
    println!("{}", g);
}
source

pub fn push_with_colspan(&mut self, cell: impl CellSource, colspan: usize)

Append a multi-column cell to the right of row.

  • cell : Contents of cell to be appended.
  • colspan : Number of columns used by the cell to be appended.

if colspan == 0, this method will do nothing.

Examples found in repository?
examples/grid_buf.rs (line 17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn main() {
    use text_grid::*;
    let mut g = GridBuilder::new();
    g.push(|b| {
        b.push(cell("name").right());
        b.push("type");
        b.push("value");
    });
    g.push_separator();
    g.push(|b| {
        b.push(cell(String::from("X")).right());
        b.push("A");
        b.push(10);
    });
    g.push(|b| {
        b.push(cell("Y").right());
        b.push_with_colspan(cell("BBB").center(), 2);
    });
    print!("{}", g);
}
source

pub fn extend<T: ?Sized + CellsSource>(&mut self, source: &T)

source

pub fn extend_with_schema<T: ?Sized>( &mut self, source: &T, schema: &dyn GridSchema<Source = T> )

Trait Implementations§

source§

impl Drop for RowBuilder<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for RowBuilder<'a>

§

impl<'a> Send for RowBuilder<'a>

§

impl<'a> Sync for RowBuilder<'a>

§

impl<'a> Unpin for RowBuilder<'a>

§

impl<'a> !UnwindSafe for RowBuilder<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.