@@ -18,39 +18,18 @@ use crate::expr::traversal::TraversalOrder;
1818///
1919/// The labeling process:
2020/// - First, `label_edge` is called on the node to produce its self-label
21- /// - Then, for each child, `merge_child` is called with `(accumulator , child_label)`
22- /// to fold the child label into the accumulator, starting with the self-label
21+ /// - Then, for each child, `merge_child` is called with `(self_label , child_label)`
22+ /// to fold the child label into the self_label
2323/// - This produces the final label for the node
2424///
25- /// This approach avoids allocating a Vec for child labels by processing them one at a time.
26- ///
2725/// # Parameters
2826///
2927/// - `expr`: The root expression to label
3028/// - `label_edge`: Function that computes a label for a single node
3129/// - `merge_child`: Mutable function that folds child labels into an accumulator.
32- /// Takes `(accumulator , child_label)` and returns the updated accumulator.
30+ /// Takes `(self_label , child_label)` and returns the updated accumulator.
3331/// Called once per child, with the initial accumulator being the node's self-label.
3432///
35- /// # Examples
36- ///
37- /// ```ignore
38- /// // Count depth of each subtree
39- /// let depths = label_tree(
40- /// expr,
41- /// |_node| 1, // Each node has depth 1 by itself
42- /// |self_depth, child_depth| self_depth.max(*child_depth + 1)
43- /// );
44- /// ```
45- ///
46- /// ```ignore
47- /// // Check if any node in subtree is null-sensitive
48- /// let sensitive = label_tree(
49- /// expr,
50- /// |node| node.is_null_sensitive(),
51- /// |acc, child| acc || *child // OR all children with self
52- /// );
53- /// ```
5433pub fn label_tree < L : Clone > (
5534 expr : & Expression ,
5635 label_edge : impl Fn ( & Expression ) -> L ,
0 commit comments