pub trait RawCell {
// 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 a cell.
Normally, cell()
or cell!
is used to create a value that implements RawCell
.
If you implement RawCell
for a type, you should also implement Cells
for convenience.
use text_grid::*;
struct X(String);
impl RawCell for X {
fn fmt(&self, s: &mut String) {
s.push_str(&self.0);
}
fn style(&self) -> CellStyle {
CellStyle::new().align_h(HorizontalAlignment::Right)
}
}
impl Cells for X {
fn fmt(f: &mut CellsFormatter<Self>) {
f.content(Cell::new);
}
}