[][src]Struct text_grid::Grid

pub struct Grid<R: ?Sized, S> { /* fields omitted */ }

A builder used to create plain-text table from values.

Examples

use text_grid::*;
struct RowData {
    a: u32,
    b: u32,
}
impl RowSource for RowData {
    fn fmt_row<'a>(w: &mut impl RowWrite<Source=&'a Self>) {
        w.column("a", |s| s.a);
        w.column("b", |s| s.b);
    }
}

let mut g = Grid::new();
g.push_row(&RowData { a: 300, b: 1 });
g.push_row(&RowData { a: 2, b: 200 });

print!("{}", g);

Output:

  a  |  b  |
-----|-----|
 300 |   1 |
   2 | 200 |

Methods

impl<R: RowSource + ?Sized> Grid<R, RowSourceGridSchema>[src]

pub fn new() -> Self[src]

Create a new Grid with RowSourceGridSchema and prepare header rows.

impl<R: ?Sized, S: GridSchema<R>> Grid<R, S>[src]

pub fn new_with_schema(schema: S) -> Self[src]

Create a new Grid with specified schema and prepare header rows.

impl<R: ?Sized, S: GridSchema<R>> Grid<R, S>[src]

pub fn push_row(&mut self, source: &R)[src]

Append a row to the bottom of the grid.

pub fn push_separator(&mut self)[src]

Append a row separator to the bottom of the grid.

Trait Implementations

impl<R: ?Sized, S> Display for Grid<R, S>[src]

impl<R: ?Sized, S> Debug for Grid<R, S>[src]

Auto Trait Implementations

impl<R, S> !Send for Grid<R, S>

impl<R, S> !Sync for Grid<R, S>

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.