1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*!
* # 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
*
* ```rust
* 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]);
* ```
*/
/// Tree iteration modules for immutable references
/// Tree iteration modules for mutable references
/// Traversal order definitions (breadth-first and depth-first)
/// Default tree implementation
/// Prelude module for convenient imports of common types