Skip to content

Commit 8acfa9c

Browse files
committed
Edits to next_dfs() docstring example.
1 parent 2544b79 commit 8acfa9c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/unit.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,12 +2053,13 @@ impl<'abbrev, 'unit, R: Reader> EntriesCursor<'abbrev, 'unit, R> {
20532053
/// // Move the cursor to the root.
20542054
/// assert!(cursor.next_dfs().unwrap().is_some());
20552055
///
2056-
/// // Keep looping while the cursor is moving deeper into the DIE tree.
2056+
/// // Traverse the DIE tree in depth-first search order.
2057+
/// let mut depth = 0;
20572058
/// while let Some((delta_depth, current)) = cursor.next_dfs().expect("Should parse next dfs") {
2058-
/// // 0 means we moved to a sibling, a negative number means we went back
2059-
/// // up to a parent's sibling. In either case, bail out of the loop because
2060-
/// // we aren't going deeper into the tree anymore.
2061-
/// if delta_depth <= 0 {
2059+
/// // Update depth value, and break out of the loop when we
2060+
/// // return to the original starting position.
2061+
/// depth += delta_depth;
2062+
/// if depth <= 0 {
20622063
/// break;
20632064
/// }
20642065
///

0 commit comments

Comments
 (0)