-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2fe0107
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
This Rust library helps you build an object tree for | ||
reo compiler of EO programs. | ||
|
||
Create a tree: | ||
|
||
```rust | ||
use cot::Tree; | ||
let tree = Tree::new(); | ||
tree.add(0); // add a vertex no.1 | ||
tree.add(1); // add a vertex no.1 | ||
tree.bind(0, 1, "foo"); // connect v0 to v1 with label "foo" | ||
tree.data(1, "Hello, world!".as_bytes()); // attachd data to v1 | ||
``` | ||
|
||
You can find a vertex by the label of an edge departing from another vertex: | ||
|
||
```rust | ||
let id = tree.kid(0, "foo"); // returns 1 | ||
``` | ||
|
||
You can find all kids of a vertex: | ||
|
||
```rust | ||
let kids: Vec<(u32, String)> = tree.kids(0); | ||
``` | ||
|
||
Then, you can print the tree: | ||
|
||
```rust | ||
println!("{:?}", tree); | ||
``` | ||
|
||
Also, you can serialize and deserialize the tree. |