Example
use veg::Veg;
struct Point {
x: f32,
y: f32,
}
impl Point {
fn new(x: f32, y: f32) -> Box<Point> {
Box::new(Point { x, y })
}
}
impl veg::Table for Point {
fn row(&self) -> Vec<String> {
[self.x, self.y].iter().map(|x| format!("${x}$")).collect()
}
}
let mut t = Veg::table("$x$|$y$\n---:|---:");
t.push(Point::new(1.0, 1.0));
t.append(&mut vec![
Point::new(2.0, 4.0),
Point::new(3.0, 9.0),
Point::new(4.0, 16.0),
]);
let markdown = t.markdown();
assert_eq!(
markdown,
" \
$x$ | $y$
-----:|-----:
$1$ | $1$
$2$ | $4$
$3$ | $9$
$4$ | $16$
\
",
);
Changelog
- 0.1.0 (2023-12-11): Initial release
- 0.1.1 (2023-12-11): Add makefile, changelog; fix readme, clippy
- 0.2.0 (2023-12-11): Convert the table function to a method