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
pub fn from_iter_with_schema<T>( source: impl IntoIterator<Item = impl Borrow<T>>, schema: impl CellsSchema<Source = T> ) -> Self
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.
pub fn extend_header<T: ?Sized + Cells>(&mut self)
pub fn extend_header_with_schema<T: ?Sized>( &mut self, schema: impl CellsSchema<Source = T> )
pub fn push_body(&mut self, source: &impl Cells)
pub fn push_body_with_schema<T: ?Sized>( &mut self, source: &T, schema: impl CellsSchema<Source = T> )
pub fn extend_body(&mut self, source: impl IntoIterator<Item = impl Cells>)
pub fn extend_body_with_schema<T>( &mut self, source: impl IntoIterator<Item = impl Borrow<T>>, schema: impl CellsSchema<Source = T> )
Trait Implementations§
source§impl Debug for GridBuilder
impl Debug for GridBuilder
source§impl Default for GridBuilder
impl Default for GridBuilder
source§impl Display for GridBuilder
impl Display for GridBuilder
source§impl<T: Cells> FromIterator<T> for GridBuilder
impl<T: Cells> FromIterator<T> for GridBuilder
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
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