tree_iter/
lib.rs

1/*!
2 * # Tree-Iter
3 *
4 * A Rust library for iterating over tree structures in different traversal orders.
5 *
6 * This library provides traits and implementations for efficient iteration over tree-like data
7 * structures in both breadth-first and depth-first traversal orders, with support for both
8 * immutable and mutable traversal.
9 *
10 * ## Features
11 *
12 * - Generic support for any tree-like structure
13 * - Breadth-first and depth-first traversal orders
14 * - Immutable and mutable iteration
15 * - Safe interior mutability during traversal using guard patterns
16 *
17 * ## Example
18 *
19 * ```rust
20 * use tree_iter::prelude::*;
21 * use tree_iter::tree::Node;
22 *
23 * // Create a simple tree
24 * let tree = Node {
25 *     value: 1,
26 *     children: vec![Node::new(2), Node::new(3)],
27 * };
28 *
29 * // Iterate over the tree in depth-first order
30 * let values: Vec<i32> = tree.iter::<DepthFirst>()
31 *                           .map(|node| node.value)
32 *                           .collect();
33 * assert_eq!(values, vec![1, 2, 3]);
34 * ```
35 */
36
37/// Tree iteration modules for immutable references
38pub mod iter;
39/// Tree iteration modules for mutable references
40pub mod iter_mut;
41/// Traversal order definitions (breadth-first and depth-first)
42pub mod traversal_order;
43/// Default tree implementation
44pub mod tree;
45
46/// Prelude module for convenient imports of common types
47pub mod prelude {
48    pub use crate::iter::{TreeIter, TreeNode};
49    pub use crate::iter_mut::{TreeIterMut, TreeNodeMut};
50    pub use crate::traversal_order::{BreadthFirst, DepthFirst, TraversalOrder};
51}