Skip to content

Commit 4f5e1ff

Browse files
committed
recursive_set documentation is revised
1 parent efac625 commit 4f5e1ff

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/node_mut.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,22 +2463,24 @@ where
24632463
/// Recursively sets the data of all nodes belonging to the subtree rooted at this node using the `compute_data`
24642464
/// function.
24652465
///
2466+
/// Alternatively, sets values of all nodes when the value of a node is defined as a function of its prior value
2467+
/// and values of its children (hence, it recursively depends on values of all descendants).
2468+
///
24662469
/// The `compute_data` function takes two arguments:
24672470
///
24682471
/// * current value (data) of this node, and
2469-
/// * slice of values of children of this node that are computed recursively using `compute_data` (*).
2472+
/// * slice of values of children of this node that are computed recursively using `compute_data` (*);
24702473
///
2471-
/// Then, `compute_data` function reduces this node's current value and new values of its children to the new
2472-
/// value of this node.
2474+
/// and then, computes the new value of this node.
24732475
///
24742476
/// The method is named *recursive* (*) due to the fact that,
24752477
///
2476-
/// * before computing the value of this node (or any of its descendants);
2477-
/// * values of all its children are computed and set using the `compute_data` function.
2478+
/// * before computing the value of this node;
2479+
/// * values of all of its children are also computed and set using the `compute_data` function.
24782480
///
2479-
/// *Note that this method does not actually make recursive method calls. Instead, it internally uses the [`PostOrder`]
2481+
/// *Note that this method does **not** actually make recursive method calls. Instead, it internally uses the [`PostOrder`]
24802482
/// traverser which ensures that all required values are computed before they are used for another computation. This
2481-
/// is a guard against potential stack overflow issues that could be observed in sufficiently large trees.*
2483+
/// is a guard against potential stack overflow issues, and hence, can be used for trees of arbitrary depth.*
24822484
///
24832485
/// [`PostOrder`]: crate::PostOrder
24842486
///
@@ -2605,8 +2607,7 @@ where
26052607
let mut children_data = Vec::<&V::Item>::new();
26062608

26072609
for ptr in iter {
2608-
let x: NodePtr<_> = ptr;
2609-
let node = unsafe { &mut *x.ptr_mut() };
2610+
let node = unsafe { &mut *ptr.ptr_mut() };
26102611
let node_data = node.data().expect("is not closed");
26112612

26122613
for child_ptr in node.next().children_ptr() {

0 commit comments

Comments
 (0)