Add more documentation comments

This commit is contained in:
Matthew Gordon 2024-10-18 20:26:33 -03:00
parent 087c2bad9b
commit f85a771071
1 changed files with 10 additions and 2 deletions

View File

@ -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<Rope>, right: Rc<Rope>) -> Rc<Self> {
/// 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<Rope>, right: Rc<Rope>) -> Rc<Self> {
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<Self>) -> NodeIterator {
NodeIterator::new(self)
}
/// Returns an iterator over the chars of the text
pub fn iter_chars(self: &Rc<Self>) -> CharIterator {
CharIterator::new(self)
}