Expand description
§Tree-Iter
A Rust library for iterating over tree structures in different traversal orders.
This library provides traits and implementations for efficient iteration over tree-like data structures in both breadth-first and depth-first traversal orders, with support for both immutable and mutable traversal.
§Features
- Generic support for any tree-like structure
- Breadth-first and depth-first traversal orders
- Immutable and mutable iteration
- Safe interior mutability during traversal using guard patterns
§Example
use tree_iter::prelude::*;
use tree_iter::tree::Node;
// Create a simple tree
let tree = Node {
value: 1,
children: vec![Node::new(2), Node::new(3)],
};
// Iterate over the tree in depth-first order
let values: Vec<i32> = tree.iter::<DepthFirst>()
.map(|node| node.value)
.collect();
assert_eq!(values, vec![1, 2, 3]);Modules§
- iter
- Tree iteration modules for immutable references
- iter_
mut - Tree iteration modules for mutable references
- prelude
- Prelude module for convenient imports of common types
- traversal_
order - Traversal order definitions (breadth-first and depth-first)
- tree
- Default tree implementation