Skip to main content

Crate generic_tree

Crate generic_tree 

Source
Expand description

This crate provides a very simple, intuitive API for storing data in a tree-like structure.

§Example

use generic_tree::{Tree, Node};

struct Data;

// Create a root Node
let mut root = Node::new("root", Data);

// Create a tree from it
let mut tree = Tree::init(root);

// Create a child
let child = Node::new("child", Data);

// And add it as a child of `root`
tree.add_node(&["root"], child);

// Get a reference to the child
let child = tree.get_node(&["root", "child"]).unwrap();

Structs§

Node
A single building block to represent an element within a Tree. Itself can contain a list of more Nodes. It should eventually be part of a Tree and it shouldn’t be necessary to keep it around on its own.
Tree
A Tree represents and owns a collection of Nodes. It should be the go-to point for interacting with elements wihtin the structure.

Enums§

Error