[][src]Struct text_grid::GridBuf

pub struct GridBuf { /* fields omitted */ }

A builder used to create plain-text table.

Examples

use text_grid::*;
let mut g = GridBuf::new();
{
    let mut row = g.push_row();
    row.push(cell("name").right());
    row.push("type");
    row.push("value");
}
g.push_separator();
{
    let mut row = g.push_row();
    row.push(cell(String::from("X")).right());
    row.push("A");
    row.push(10);
}
{
    let mut row = g.push_row();
    row.push(cell("Y").right());
    row.push_with_colspan(cell("BBB").center(), 2);
}

print!("{}", g);

Output:

 name | type | value |
------|------|-------|
    X | A    |    10 |
    Y |     BBB      |

Methods

impl GridBuf[src]

pub fn new() -> Self[src]

Create a new GridBuf.

pub fn set_column_separators(&mut self, separators: Vec<bool>)[src]

Set column separator's visibility.

separators[0] indicate visibility of the right side of the leftmost column.

Examples

use text_grid::*;
let mut g = GridBuf::new();
{
    let mut row = g.push_row();
    row.push("A");
    row.push("B");
    row.push("C");
}
{
    let mut row = g.push_row();
    row.push("AAA");
    row.push("BBB");
    row.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);

Output:

[true, true]
 A   | B   | C   |
 AAA | BBB | CCC |

[false, true]
 A  B   | C   |
 AAABBB | CCC |  

pub fn push_row(&mut self) -> RowBuf[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 Default for GridBuf[src]

impl Display for GridBuf[src]

impl Debug for GridBuf[src]

Auto Trait Implementations

impl Send for GridBuf

impl Sync for GridBuf

Blanket Implementations

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

impl<T> From for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[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.