[−][src]Struct text_grid::GridBuf
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
Auto Trait Implementations
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,