pub struct TreeSlice<'a> { /* private fields */ }Expand description
A zero-copy borrowed view over a byte range of the tree. All offsets are relative to the slice start.
Implementations§
Source§impl<'a> TreeSlice<'a>
impl<'a> TreeSlice<'a>
pub fn new(tree: &'a PieceTree, start: u32, end: u32) -> Self
pub fn len_bytes(&self) -> u32
pub fn is_empty(&self) -> bool
pub fn len_chars(&self) -> u32
pub fn len_lines(&self) -> u32
Sourcepub fn chunks(&self) -> ChunkIter<'a> ⓘ
pub fn chunks(&self) -> ChunkIter<'a> ⓘ
Non-allocating chunk iterator over the slice’s byte range.
Sourcepub fn chars(&self) -> SliceChars<'a> ⓘ
pub fn chars(&self) -> SliceChars<'a> ⓘ
Non-allocating char iterator over the slice.
Sourcepub fn line(&self, line: u32) -> Option<ChunkIter<'a>>
pub fn line(&self, line: u32) -> Option<ChunkIter<'a>>
Non-allocating chunk iterator over a slice-relative line.
Sourcepub fn slice<R: RangeBounds<u32>>(&self, range: R) -> TreeSlice<'a>
pub fn slice<R: RangeBounds<u32>>(&self, range: R) -> TreeSlice<'a>
Returns a sub-slice over a byte range (relative to this slice).
pub fn byte_to_char(&self, byte_offset: u32) -> Option<u32>
pub fn char_to_byte(&self, char_index: u32) -> Option<u32>
pub fn byte_to_line(&self, byte_offset: u32) -> Option<u32>
pub fn line_to_byte(&self, line: u32) -> Option<u32>
pub fn abs_line_range(&self, rel_line: u32) -> Option<(u32, u32)>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TreeSlice<'a>
impl<'a> RefUnwindSafe for TreeSlice<'a>
impl<'a> Send for TreeSlice<'a>
impl<'a> Sync for TreeSlice<'a>
impl<'a> Unpin for TreeSlice<'a>
impl<'a> UnsafeUnpin for TreeSlice<'a>
impl<'a> UnwindSafe for TreeSlice<'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