tabled
An easy to use library for pretty printing tables of Rust structs and enums.
There are more examples and you can find in this README.
Usage
To print a list of structs or enums as a table your types should implement the the Tabled trait or derive it with a #[derive(Tabled)] macro.
Most of the default types implement the trait out of the box.
use ;
let languages = vec!;
let table = new.to_string;
let expected = "+------+----------------+---------------+\n\
| name | designed_by | invented_year |\n\
+------+----------------+---------------+\n\
| C | Dennis Ritchie | 1972 |\n\
+------+----------------+---------------+\n\
| Go | Rob Pike | 2009 |\n\
+------+----------------+---------------+\n\
| Rust | Graydon Hoare | 2010 |\n\
+------+----------------+---------------+\n\
| Hare | Drew DeVault | 2022 |\n\
+------+----------------+---------------+";
assert_eq!;
The same example but we are building a table step by step.
use ;
let mut builder = new;
builder.push_record;
builder.push_record;
builder.push_record;
builder.push_record;
let mut table = builder.build;
table.with;
let table = table.to_string;
assert_eq!;