quercus
quercus is the scientific genus name for oak trees.
This crate was inspired by ptree.
Main features
This crate allows you to create trees with many roots.
This crate does not have a syntax distinction for the first node/branch of a given root.
The crate also does not have a syntax distinction for nodes that do not have branches (leaves) or nodes that do.
This makes it easy to create a tree recursively, as the information is not needed when adding a new node.
This crate also provides a (small) variety of branch styles and a versatile indentation option that may be invoked spontaneously during the construction of the tree.
Usage
The following code
let mut tree = new;
tree.node;
tree.begin_branches;
tree.node;
tree.node;
tree.end_branches;
tree.prune;
println!;
results in:
For a node with many lines use the node_many_lines() command.
For example, the code
let mut tree = new.style.indent;
tree.node;
tree.begin_branches;
tree.node_many_lines;
tree.begin_branches;
tree.node;
tree.node;
tree.end_branches;
tree.indent; // Change indentation
tree.node;
tree.begin_branches;
tree.node;
tree.node;
tree.end_branches;
tree.end_branches;
tree.prune_and_print;
results in:
)
Appearance Options
Indentation
The indentation of the branches can be set through the indent() command, which expects a usize integer.
This command can be invoked anywhere during the construction of the tree.
Branch Style
The style of the branches can be set through the style() command, which expects a PipeStyle enum variant.
Currently, the following variants are available:
PipeStyle::Simple:│─├└PipeStyle::Curvy:│─├╰PipeStyle::Double:║═╠╚PipeStyle::Thick:┃━┣┗
This command, however, may only be invoked at the root level of the tree.
Crate Examples
For an example that builds a tree recursively, run
This should yield the following output:
For an example that uses the colored crate as well as the node_many_lines() command, run
License
This project is licensed under either
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)