pub enum RopeNode {
Leaf(RopeLeaf),
Internal(RopeInternal),
}Expand description
A node in the balanced B-Tree Rope hierarchy (either an internal branch or a leaf node).
Variants§
Leaf(RopeLeaf)
Internal(RopeInternal)
Implementations§
Source§impl RopeNode
impl RopeNode
pub fn metrics(&self) -> SubtreeMetrics
pub fn line_count(&self) -> usize
pub fn char_count(&self) -> usize
pub fn byte_count(&self) -> usize
pub fn height(&self) -> usize
pub fn get_line(&self, line_idx: usize) -> Option<&str>
pub fn get_line_mut(&mut self, line_idx: usize) -> Option<&mut String>
pub fn insert_char(&mut self, line_idx: usize, col: usize, ch: char)
pub fn insert_str_single_line( &mut self, line_idx: usize, col: usize, text: &str, )
pub fn delete_char_at(&mut self, line_idx: usize, col: usize) -> Option<usize>
pub fn split_line(&mut self, line_idx: usize, col: usize) -> SplitResult
pub fn append_to_line(&mut self, line_idx: usize, text: &str)
pub fn insert_line(&mut self, line_idx: usize, text: String) -> SplitResult
pub fn delete_line(&mut self, line_idx: usize) -> Option<String>
pub fn slice_lines<'a>( &'a self, line_offset: usize, start: usize, end: usize, out: &mut Vec<(usize, &'a str)>, )
Sourcepub fn mutate_line<R>(
&mut self,
line_idx: usize,
f: impl FnOnce(&mut String) -> R,
) -> Option<(R, isize, isize)>
pub fn mutate_line<R>( &mut self, line_idx: usize, f: impl FnOnce(&mut String) -> R, ) -> Option<(R, isize, isize)>
Mutates the line at line_idx in place and bubbles exact (chars, bytes) metric deltas
up the B-Tree spine in O(log N), keeping SubtreeMetrics strictly invariant.
Sourcepub fn position_to_byte(&self, line_idx: usize, char_col: usize) -> usize
pub fn position_to_byte(&self, line_idx: usize, char_col: usize) -> usize
Computes the exact byte offset of (line_idx, char_col) in the \n-joined document
in O(log N) time using cached SubtreeMetrics.
Sourcepub fn byte_to_position(
&self,
byte_offset: usize,
line_base: usize,
) -> (usize, usize)
pub fn byte_to_position( &self, byte_offset: usize, line_base: usize, ) -> (usize, usize)
Converts a byte offset in the \n-joined document into (line_idx, char_col) in O(log N).
pub fn write_text(&self, out: &mut String, is_first: &mut bool)
Trait Implementations§
impl Eq for RopeNode
impl StructuralPartialEq for RopeNode
Auto Trait Implementations§
impl Forget for RopeNode
impl Freeze for RopeNode
impl Move for RopeNode
impl RefUnwindSafe for RopeNode
impl Send for RopeNode
impl Sync for RopeNode
impl Unpin for RopeNode
impl UnsafeUnpin for RopeNode
impl UnwindSafe for RopeNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.