A rust library for creating and then navigating read-only trees.
Add the following to your
 = "0.1"
Trees are created using the builder struct
Sapling. Nodes can be attached to
a sapling by using
push(_). When a node is added to a sapling it is also
selected as the parent for later nodes. To finish a node and select its parent
pop(). When adding a node with no children
push_leaf(_) can be used;
it behaves the same as
All changes to a sapling return a
Result. This is done because the sapling
ensures certain qualities of your tree. For instance it ensures there is
exactly one root.
When the sapling is complete you can use
build() to turn the sapling into
Tree. The resulting tree can no longer be modified. Navigating trees is
done by using slices of trees called
Nodes. To get started use
root() on a
tree to get its root node.
Nodes support various iterators to navigate their contents.
use read-Sapling; let sap = new; sap.push.unwrap; let tree = sap.build.unwrap; let root = tree.root; assert_eq!;