#tree #collection #tree-node #structure #storing #generic

yanked generic-tree

A very simple, intuitive API for storing data in a tree-like structure

0.2.0 May 25, 2020
0.1.2 May 22, 2020
0.1.1 May 22, 2020
0.1.0 May 22, 2020
0.0.0 May 21, 2020

#75 in #storing

MIT license

16KB
189 lines

generic-tree

Regression License Documentation

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

Example

To get started, add the following to Cargo.toml.

generic-tree = "0.1"
use generic_tree::{Tree, Node};

struct Data;

fn main() {

    // 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();
}

No runtime deps