pub struct Cell<T> { /* private fields */ }Expand description
Implementation of CellSource that can specify styles.
Implementations§
source§impl<T: CellSource> Cell<T>
impl<T: CellSource> Cell<T>
sourcepub fn new(source: T) -> Self
pub fn new(source: T) -> Self
Create a new Cell with specified CellSource.
sourcepub fn right(self) -> Self
pub fn right(self) -> Self
Return the cell with horizontal alignment set to the right.
Examples found in repository?
More examples
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);
}sourcepub fn center(self) -> Self
pub fn center(self) -> Self
Return the cell with horizontal alignment set to the center.
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);
}sourcepub fn baseline(self, baseline: &str) -> impl CellsSource
pub fn baseline(self, baseline: &str) -> impl CellsSource
Return the cell with aligned baseline.
use text_grid::*;
struct Source(&'static str);
impl CellsSource for Source {
fn fmt(f: &mut CellsFormatter<&Self>) {
f.column("default", |x| &x.0);
f.column("baseline", |x| cell(&x.0).baseline("-"));
}
}
let mut g = Grid::new();
g.push(&Source("1-2345"));
g.push(&Source("1234-5"));
g.push(&Source("12345"));
assert_eq!(format!("\n{g}"), r#"
default | baseline |
---------|------------|
1-2345 | 1-2345 |
1234-5 | 1234-5 |
12345 | 12345 |
"#);sourcepub fn with_base_style(self, style: CellStyle) -> Self
pub fn with_base_style(self, style: CellStyle) -> Self
Return the cell with an empty style replaced by the specified style.
Judgment as to whether the style is empty or not is done for each individual element.
Trait Implementations§
source§impl<T: CellSource> CellSource for Cell<T>
impl<T: CellSource> CellSource for Cell<T>
source§impl<T: CellSource> CellsSource for Cell<T>
impl<T: CellSource> CellsSource for Cell<T>
source§fn fmt(f: &mut CellsFormatter<'_, &Self>)
fn fmt(f: &mut CellsFormatter<'_, &Self>)
Define columns. see
CellsFormatter for details.Auto Trait Implementations§
impl<T> RefUnwindSafe for Cell<T>where T: RefUnwindSafe,
impl<T> Send for Cell<T>where T: Send,
impl<T> Sync for Cell<T>where T: Sync,
impl<T> Unpin for Cell<T>where T: Unpin,
impl<T> UnwindSafe for Cell<T>where T: UnwindSafe,
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