macro_rules! cell {
($ ( $ arg : tt ) *) => { ... };
}
Expand description
Creates a Cell
using interpolation of runtime expressions.
Use the format!
syntax to create Cell
. See std::fmt
for more information.
Examples
use text_grid::*;
struct RowData {
a: f64,
b: f64,
}
impl RowSource for RowData {
fn fmt_row<'a>(w: &mut impl RowWrite<'a, Self>) {
w.column("a", |s| cell!("{:.2}", s.a).right());
w.column("b", |s| cell!("{:.3}", s.b).right());
}
}
let mut g = Grid::new();
g.push_row(&RowData { a: 1.10, b: 1.11 });
g.push_row(&RowData { a: 1.00, b: 0.10 });
print!("{}", g);
output
a | b |
------|-------|
1.10 | 1.110 |
1.00 | 0.100 |