pub struct Rope<'a> { /* private fields */ }Expand description
A rope data structure.
Implementations§
Source§impl<'a> Rope<'a>
impl<'a> Rope<'a>
Sourcepub fn add(&mut self, value: &'a str)
pub fn add(&mut self, value: &'a str)
Adds a string slice to the end of the rope.
Converts from simple to complex representation on first add. Empty strings are ignored.
Sourcepub fn append(&mut self, value: Rope<'a>)
pub fn append(&mut self, value: Rope<'a>)
Appends another rope to this rope.
Handles all combinations of simple and complex representations efficiently.
Sourcepub fn get_byte(&self, byte_index: usize) -> Option<u8>
pub fn get_byte(&self, byte_index: usize) -> Option<u8>
Non-panicking version of Rope::byte.
Gets the byte at the given index, returning None if out of bounds.
Sourcepub fn char_indices(&self) -> CharIndices<'_>
pub fn char_indices(&self) -> CharIndices<'_>
Returns an iterator over the characters and their byte positions.
Sourcepub fn starts_with(&self, value: &Rope<'_>) -> bool
pub fn starts_with(&self, value: &Rope<'_>) -> bool
Returns whether the rope starts with the given string.
Sourcepub fn ends_with(&self, value: char) -> bool
pub fn ends_with(&self, value: char) -> bool
Returns whether the rope ends with the given string.
Sourcepub fn byte_slice<R>(&self, range: R) -> Rope<'a>where
R: RangeBounds<usize>,
pub fn byte_slice<R>(&self, range: R) -> Rope<'a>where
R: RangeBounds<usize>,
Returns a slice of the rope in the given byte range.
§Panics
- When start > end
- When end is out of bounds
- When indices are not on char boundaries
Sourcepub fn get_byte_slice<R>(&self, range: R) -> Option<Rope<'a>>where
R: RangeBounds<usize>,
pub fn get_byte_slice<R>(&self, range: R) -> Option<Rope<'a>>where
R: RangeBounds<usize>,
Non-panicking version of Rope::byte_slice.
Sourcepub unsafe fn byte_slice_unchecked<R>(&self, range: R) -> Rope<'a>where
R: RangeBounds<usize>,
pub unsafe fn byte_slice_unchecked<R>(&self, range: R) -> Rope<'a>where
R: RangeBounds<usize>,
Range-unchecked version of Rope::byte_slice.
§Safety
This is not safe, due to the following invariants that must be upheld:
- Range must be within bounds.
- Range start must be less than or equal to the end.
- Both range start and end must be on char boundaries.
Trait Implementations§
Source§impl<'a> FromIterator<&'a str> for Rope<'a>
impl<'a> FromIterator<&'a str> for Rope<'a>
Auto Trait Implementations§
impl<'a> Freeze for Rope<'a>
impl<'a> RefUnwindSafe for Rope<'a>
impl<'a> !Send for Rope<'a>
impl<'a> !Sync for Rope<'a>
impl<'a> Unpin for Rope<'a>
impl<'a> UnwindSafe for Rope<'a>
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more