pub struct TreeNode { /* private fields */ }Expand description
A node system that will display as a tree in the terminal using unicode characters. Originally designed to display the Abstract Syntax Tree of my Programming language.
§Example:
use cli_tree::TreeNode;
// This will print:
// Test Node
// ├─Child 1
// ├─Child 2
// │ ├─Child 2.1
// │ ├─Child 2.2
// │ ├─Child 2.3
// │ │ ├─Child 2.3.1
// │ │ └─Child 2.3.2
// │ └─Child 2.4
// │ ├─Child 2.4.1
// │ ├─Child 2.4.2
// │ └─Child 2.4.3
// └─Child 3
let mut node = TreeNode::new("Test Node");
// add a single child
node.add_child(TreeNode::new("Child 1"));
// add a child with children which also have children
node.add_child(TreeNode::new_with_children("Child 2",
vec![TreeNode::new("Child 2.1"),
TreeNode::new("Child 2.2"),
TreeNode::new_with_children("Child 2.3",
vec![TreeNode::new("Child 2.3.1"),
TreeNode::new("Child 2.3.2")]),
TreeNode::new_with_children("Child 2.4",
vec![TreeNode::new("Child 2.4.1"),
TreeNode::new("Child 2.4.2"),
TreeNode::new("Child 2.4.3")])]));
// add another singular child
node.add_child(TreeNode::new("Child 3"));
println!("{}", node);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TreeNode
impl RefUnwindSafe for TreeNode
impl Send for TreeNode
impl Sync for TreeNode
impl Unpin for TreeNode
impl UnwindSafe for TreeNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more