Function root

Source
pub fn root(root: impl Into<String>) -> Tree
Expand description

Creates a new tree with the specified root value.

This is a convenience function equivalent to Tree::new().root(root).

§Arguments

  • root - The root value for the tree (anything convertible to String)

§Returns

A new Tree instance with the specified root value

§Examples

use lipgloss_tree::{root, Node, Children};

let tree = root("My Project")
    .child(vec!["file1.txt".into(), "file2.txt".into()]);

assert_eq!(tree.value(), "My Project");
assert_eq!(tree.children().length(), 2);