Struct text_grid::RowBuilder
source · pub struct RowBuilder<'a> { /* private fields */ }Expand description
A builder used to create row of GridBuilder.
This structure is created by GridBuilder::push.
Implementations§
source§impl RowBuilder<'_>
impl RowBuilder<'_>
sourcepub fn push(&mut self, cell: impl CellSource)
pub fn push(&mut self, cell: impl CellSource)
Append a cell to the right of row.
Examples found in repository?
examples/grid_buf.rs (line 5)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
fn main() {
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);
});
print!("{}", g);
}More examples
examples/set_column_separators.rs (line 5)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() {
use text_grid::*;
let mut g = GridBuilder::new();
g.push(|b| {
b.push("A");
b.push("B");
b.push("C");
});
g.push(|b| {
b.push("AAA");
b.push("BBB");
b.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);
}sourcepub fn push_with_colspan(&mut self, cell: impl CellSource, colspan: usize)
pub fn push_with_colspan(&mut self, cell: impl CellSource, colspan: usize)
Append a multi-column cell to the right of row.
cell: Contents of cell to be appended.colspan: Number of columns used by the cell to be appended.
if colspan == 0, this method will do nothing.
Examples found in repository?
examples/grid_buf.rs (line 17)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
fn main() {
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);
});
print!("{}", g);
}pub fn extend<T: ?Sized + CellsSource>(&mut self, source: &T)
pub fn extend_with_schema<T: ?Sized>( &mut self, source: &T, schema: &dyn GridSchema<Source = T> )
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for RowBuilder<'a>
impl<'a> Send for RowBuilder<'a>
impl<'a> Sync for RowBuilder<'a>
impl<'a> Unpin for RowBuilder<'a>
impl<'a> !UnwindSafe for RowBuilder<'a>
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