Trees in Rust

Trees are one of the most basic data structures. So, how are they supported in Rust?

In general, you can checkout https://crates.io/keywords/tree

Below is a table of specially selected crates. The less features, the fastest the implementation. So, if you are going to pick one, choose the one that exactly fits your use case.

</table> ✔: Efficiently implemented ❌: Should not be used for this ❓: Could be implemented? ❗: Could be efficiently implemented There are a few utility crates that might improve your experience. - Visualize - [termtree](https://crates.io/crates/termtree) - [treeline](https://crates.io/crates/treeline) - [ptree](https://crates.io/crates/ptree) - Traverse - [petgraph](https://crates.io/crates/petgraph) - Visit, Walker - [traversal](https://crates.io/crates/traversal) - Takes reference to the tree
feature\crate tree-flat ego-tree description
stable node id Nodes have a unique id that never invalidates
root Get root id
get node Get a node form an id
mutate values Get mutable reference to node values
children Get children of a node
parent Get the parent of a node
siblings ✔ (separated in next_ and previous_siblings) Get the siblings of a node
detach Node can not bea accessed anymore/td> </tr>
remove Node is not part of the tree