0.2.0 |
|
---|---|
0.1.2 |
|
0.1.1 |
|
0.1.0 |
|
0.0.0 |
|
#75 in #storing
16KB
189 lines
generic-tree
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();
}