pub struct Rope { /* private fields */ }Expand description
Rope-backed text storage.
Implementations§
Source§impl Rope
impl Rope
Sourcepub fn from_text(s: &str) -> Self
pub fn from_text(s: &str) -> Self
Create a rope from a string slice.
This is a convenience method. You can also use .parse() or From<&str>.
Sourcepub fn slice<R>(&self, range: R) -> Cow<'_, str>where
R: RangeBounds<usize>,
pub fn slice<R>(&self, range: R) -> Cow<'_, str>where
R: RangeBounds<usize>,
Get a slice of the rope by character range.
Sourcepub fn insert_grapheme(&mut self, grapheme_idx: usize, text: &str)
pub fn insert_grapheme(&mut self, grapheme_idx: usize, text: &str)
Insert text at a grapheme index.
Sourcepub fn remove<R>(&mut self, range: R)where
R: RangeBounds<usize>,
pub fn remove<R>(&mut self, range: R)where
R: RangeBounds<usize>,
Remove a character range.
Sourcepub fn remove_grapheme_range<R>(&mut self, range: R)where
R: RangeBounds<usize>,
pub fn remove_grapheme_range<R>(&mut self, range: R)where
R: RangeBounds<usize>,
Remove a grapheme range.
Sourcepub fn char_to_byte(&self, char_idx: usize) -> usize
pub fn char_to_byte(&self, char_idx: usize) -> usize
Convert a character index to a byte index.
Sourcepub fn byte_to_char(&self, byte_idx: usize) -> usize
pub fn byte_to_char(&self, byte_idx: usize) -> usize
Convert a byte index to a character index.
Sourcepub fn char_to_line(&self, char_idx: usize) -> usize
pub fn char_to_line(&self, char_idx: usize) -> usize
Convert a character index to a line index.
Sourcepub fn line_to_char(&self, line_idx: usize) -> usize
pub fn line_to_char(&self, line_idx: usize) -> usize
Get the character index at the start of a line.
Sourcepub fn byte_to_line_col(&self, byte_idx: usize) -> (usize, usize)
pub fn byte_to_line_col(&self, byte_idx: usize) -> (usize, usize)
Convert a byte index to (line, column) in characters.
Sourcepub fn line_col_to_byte(&self, line_idx: usize, col: usize) -> usize
pub fn line_col_to_byte(&self, line_idx: usize, col: usize) -> usize
Convert (line, column) in characters to a byte index.
Sourcepub fn grapheme_count(&self) -> usize
pub fn grapheme_count(&self) -> usize
Count grapheme clusters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Rope
impl RefUnwindSafe for Rope
impl Send for Rope
impl Sync for Rope
impl Unpin for Rope
impl UnwindSafe for Rope
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