Add more documentation comments
This commit is contained in:
parent
087c2bad9b
commit
f85a771071
|
|
@ -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 {
|
pub fn total_lines(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Rope::Branch {
|
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 {
|
Rc::new(Rope::Branch {
|
||||||
bytes_weight: left.total_bytes(),
|
bytes_weight: left.total_bytes(),
|
||||||
chars_weight: left.total_chars(),
|
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 {
|
pub fn is_leaf(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Rope::Branch { .. } => false,
|
Rope::Branch { .. } => false,
|
||||||
|
|
@ -105,10 +111,12 @@ impl Rope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an iterater over the leaf nodes
|
||||||
fn iter_nodes(self: Rc<Self>) -> NodeIterator {
|
fn iter_nodes(self: Rc<Self>) -> NodeIterator {
|
||||||
NodeIterator::new(self)
|
NodeIterator::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an iterator over the chars of the text
|
||||||
pub fn iter_chars(self: &Rc<Self>) -> CharIterator {
|
pub fn iter_chars(self: &Rc<Self>) -> CharIterator {
|
||||||
CharIterator::new(self)
|
CharIterator::new(self)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue