Struct text_grid::GridBuilder
source · pub struct GridBuilder {
pub column_styles: Vec<ColumnStyle>,
/* private fields */
}Expand description
A builder used to create plain-text table.
Examples
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);
});
assert_eq!(format!("\n{g}"), r#"
name | type | value |
------|------|-------|
X | A | 10 |
Y | BBB |
"#);Fields§
§column_styles: Vec<ColumnStyle>Implementations§
source§impl GridBuilder
impl GridBuilder
sourcepub fn push(&mut self, f: impl FnOnce(&mut RowBuilder<'_>))
pub fn push(&mut self, f: impl FnOnce(&mut RowBuilder<'_>))
Append a row to the bottom of the grid.
sourcepub fn push_separator(&mut self)
pub fn push_separator(&mut self)
Append a row separator to the bottom of the grid.
Trait Implementations§
source§impl Debug for GridBuilder
impl Debug for GridBuilder
source§impl Default for GridBuilder
impl Default for GridBuilder
Auto Trait Implementations§
impl RefUnwindSafe for GridBuilder
impl Send for GridBuilder
impl Sync for GridBuilder
impl Unpin for GridBuilder
impl UnwindSafe for GridBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more