A library which easily formats tree structures into a view. This can be the output of an cli or part of a view in a tui.
Tree structures just need to implement the trait TreeView.
The trait TreeView has only one implementation of the function fn to_node(&self) -> Node
.
An example implementation for the struct TestMap:
#derive[Eq, Ord, PartialEq, PartialOrd]
pub struct TestMap {
pub key: String,
pub value: Vec<TestMap>,
}
impl ToTreeView for TestMap {
fn to_node(&self) -> Node {
node: self.key.clone(),
children: self.value.iter().map(|v| v.to_node()).collect(),
}
}
Output of a TestMap:
Root
├── Leaf1
├── Node1
│ ├── Leaf2
│ └── Node2
│ ├── Leaf3
│ └── Leaf4
├── Node3
│ └── Leaf5
└── Node4
└── Leaf6
You need to install cargo on your system through your package manager or any other means.
Then you simply install it through cargo.
$ > cargo install tree_view
You need to install cargo on your system through your package manager or any other means.
The you download the repository through git or manual.
After unpacking or downloading from git you have to switch into the folder of tree_view.
Then run cargo install --path .
.
$ > cd tree_view
$ > cargo install --path .
tree_view is dual licensed under MIT License and Apache 2 License