Trait text_grid::CellSource
source · pub trait CellSource {
// Required method
fn fmt(&self, s: &mut String);
// Provided methods
fn style(&self) -> CellStyle { ... }
fn style_for_body(&self) -> CellStyle { ... }
}Expand description
A data structure that can be formatted into cell.
Normally, cell() or cell! is used to create a value that implements CellSource.
If you implement CellSource for a type, you should also implement CellsSource for convenience.
use text_grid::*;
struct X(String);
impl CellSource for X {
fn fmt(&self, s: &mut String) {
s.push_str(&self.0);
}
fn style(&self) -> CellStyle {
CellStyle::new().align_h(HorizontalAlignment::Right)
}
}
impl CellsSource for X {
fn fmt(f: &mut CellsFormatter<&Self>) {
f.content(|x| Cell::new(*x));
}
}