diff --git a/src/core/rope.rs b/src/core/rope.rs index e348be4..ef74e29 100644 --- a/src/core/rope.rs +++ b/src/core/rope.rs @@ -71,7 +71,7 @@ impl Rope { } } - // Return the total number of lines in the text + /// Return the total number of lines in the text pub fn total_lines(&self) -> usize { match self { Rope::Branch { @@ -88,7 +88,12 @@ impl Rope { } } - pub fn join(left: Rc, right: Rc) -> Rc { + /// Concatenate two Ropes without rebalancing. + /// + /// Combines to ropes by creating a new parent node and adding `left` and + /// `right` as children. Having this separate from [Rope::concatenate()] is mostly + /// useful for testing purposes. + fn join(left: Rc, right: Rc) -> Rc { Rc::new(Rope::Branch { bytes_weight: left.total_bytes(), chars_weight: left.total_chars(), @@ -98,6 +103,7 @@ impl Rope { }) } + /// Returns true if this node is a leaf node, false otherwise pub fn is_leaf(&self) -> bool { match self { Rope::Branch { .. } => false, @@ -105,10 +111,12 @@ impl Rope { } } + /// Returns an iterater over the leaf nodes fn iter_nodes(self: Rc) -> NodeIterator { NodeIterator::new(self) } + /// Returns an iterator over the chars of the text pub fn iter_chars(self: &Rc) -> CharIterator { CharIterator::new(self) }