Skip to content

Commit 666486f

Browse files
authored
Merge pull request #375 from kaesluder/trav-desc-doc
Expand traverse and descendants documentation: Issue #369
2 parents 2c2de3f + a264526 commit 666486f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/arena_tree.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,36 @@ impl<'a, T> Node<'a, T> {
136136
ReverseChildren(self.last_child.get())
137137
}
138138

139-
/// Return an iterator of references to this node and its descendants, in tree order.
139+
/// Return an iterator of references to this `Node` and its descendants, in tree order.
140140
///
141141
/// Parent nodes appear before the descendants.
142142
/// Call `.next().unwrap()` once on the iterator to skip the node itself.
143+
///
144+
/// *Similar Functions:* Use `traverse()` or `reverse_traverse` if you need
145+
/// references to the `NodeEdge` structs associated with each `Node`
143146
pub fn descendants(&'a self) -> Descendants<'a, T> {
144147
Descendants(self.traverse())
145148
}
146149

147-
/// Return an iterator of references to this node and its descendants, in tree order.
150+
/// Return an iterator of references to `NodeEdge` enums for each `Node` and its descendants,
151+
/// in tree order.
152+
///
153+
/// `NodeEdge` enums represent the `Start` or `End` of each node.
154+
///
155+
/// *Similar Functions:* Use `descendants()` if you don't need `Start` and `End`.
148156
pub fn traverse(&'a self) -> Traverse<'a, T> {
149157
Traverse {
150158
root: self,
151159
next: Some(NodeEdge::Start(self)),
152160
}
153161
}
154162

155-
/// Return an iterator of references to this node and its descendants, in tree order.
163+
/// Return an iterator of references to `NodeEdge` enums for each `Node` and its descendants,
164+
/// in *reverse* order.
165+
///
166+
/// `NodeEdge` enums represent the `Start` or `End` of each node.
167+
///
168+
/// *Similar Functions:* Use `descendants()` if you don't need `Start` and `End`.
156169
pub fn reverse_traverse(&'a self) -> ReverseTraverse<'a, T> {
157170
ReverseTraverse {
158171
root: self,

0 commit comments

Comments
 (0)