A library for converting ron to a table.
It uses tabled as a rendering backend.
Get started
The library supports 2 modes for a table embedded and collapsed. It also provides with a list of options to modify the table, such as style, alignment, padding and more.
You can change an orientation of a map and sequence via Orientation.
You'll find to examples for the modes bellow.
Usage
Add the library to a dependency list.
[]
= "0.1.0"
let data = r#"Scene(
materials: {
"metal": (reflectivity: 1.0),
"plastic": (reflectivity: 0.5),
},
entities: [
(name: "hero", material: "metal"),
(name: "monster", material: "plastic"),
],
)"#;
let scene = from_str.unwrap;
let table = to_string;
println!;
+-------------+--------------------------------------------+
| entities | +----------------------------+ |
| | | +------------+---------+ | |
| | | | material | metal | | |
| | | +------------+---------+ | |
| | | | name | hero | | |
| | | +------------+---------+ | |
| | +----------------------------+ |
| | | +------------+-----------+ | |
| | | | material | plastic | | |
| | | +------------+-----------+ | |
| | | | name | monster | | |
| | | +------------+-----------+ | |
| | +----------------------------+ |
+-------------+--------------------------------------------+
| materials | +-----------+----------------------------+ |
| | | metal | +----------------+-----+ | |
| | | | | reflectivity | 1 | | |
| | | | +----------------+-----+ | |
| | +-----------+----------------------------+ |
| | | plastic | +----------------+-------+ | |
| | | | | reflectivity | 0.5 | | |
| | | | +----------------+-------+ | |
| | +-----------+----------------------------+ |
+-------------+--------------------------------------------+
use RonTable;
use Style;
let data = r#"Scene(
materials: {
"metal": (reflectivity: 1.0),
"plastic": (reflectivity: 0.5),
},
entities: [
(name: "hero", material: "metal"),
(name: "monster", material: "plastic"),
],
)"#;
let scene = from_str.unwrap;
let table = default
.collapse
.with
.build;
println!;
╔═══════════╦══════════╦═══════════════════╗
║ entities ║ material ║ metal ║
║ ╠══════════╬═══════════════════╣
║ ║ name ║ hero ║
║ ╠══════════╬═══════════════════╣
║ ║ material ║ plastic ║
║ ╠══════════╬═══════════════════╣
║ ║ name ║ monster ║
╠═══════════╬═════════╦╩═════════════╦═════╣
║ materials ║ metal ║ reflectivity ║ 1 ║
║ ╠═════════╬══════════════╬═════╣
║ ║ plastic ║ reflectivity ║ 0.5 ║
╚═══════════╩═════════╩══════════════╩═════╝