pub struct Document { /* private fields */ }Implementations§
Source§impl Document
impl Document
pub fn new(text: &str) -> Self
Sourcepub fn chunks(&self) -> impl Iterator<Item = &str> + '_
pub fn chunks(&self) -> impl Iterator<Item = &str> + '_
The text in order, in the rope’s pieces (for hashing without a copy).
Sourcepub fn len(&self) -> ByteOffset
pub fn len(&self) -> ByteOffset
Length in bytes; also the offset of the end of the document.
pub fn is_empty(&self) -> bool
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Number of lines. An empty document, or one ending in \n, still has a
(possibly empty) last line.
Sourcepub fn line_of(&self, pos: ByteOffset) -> usize
pub fn line_of(&self, pos: ByteOffset) -> usize
Line containing pos. A \n belongs to the line it ends.
pub fn line_start(&self, line: usize) -> ByteOffset
Sourcepub fn line_end(&self, line: usize) -> ByteOffset
pub fn line_end(&self, line: usize) -> ByteOffset
End of the line’s content, excluding its \n.
pub fn slice(&self, range: Range<ByteOffset>) -> String
pub fn is_char_boundary(&self, pos: ByteOffset) -> bool
Sourcepub fn chunk_at(&self, pos: ByteOffset) -> (&str, ByteOffset)
pub fn chunk_at(&self, pos: ByteOffset) -> (&str, ByteOffset)
The chunk of text containing pos and the offset at which it starts.
At the end of the document this is the last chunk. Grapheme segmentation
in position walks the rope with this.
Sourcepub fn char_at(&self, pos: ByteOffset) -> Option<char>
pub fn char_at(&self, pos: ByteOffset) -> Option<char>
The char starting at pos, if any.
pub fn to_char_idx(&self, pos: ByteOffset) -> CharIdx
Sourcepub fn replace(&mut self, range: Range<ByteOffset>, text: &str)
pub fn replace(&mut self, range: Range<ByteOffset>, text: &str)
Replaces range with text. Both ends must be char boundaries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
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