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>
Slice Iterators
impl<'a> TreeSlice<'a>
Slice Iterators
pub fn chunks(self) -> ChunkIter<'a> ⓘ
pub fn bytes(self) -> impl Iterator<Item = u8> + 'a
pub fn chars(self) -> impl Iterator<Item = char> + 'a
pub fn chars_rev(self) -> SliceCharsRev<'a> ⓘ
pub fn lines(self) -> SliceLines<'a> ⓘ
pub fn lines_at(self, line_idx: u32) -> SliceLines<'a> ⓘ
pub fn chunks_at_byte(self, byte_idx: u32) -> ChunkIter<'a> ⓘ
pub fn bytes_at(self, byte_idx: u32) -> impl Iterator<Item = u8> + 'a
pub fn chars_at(self, char_idx: u32) -> impl Iterator<Item = char> + 'a
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
pub fn chunk_at_byte(&self, offset: u32) -> &[u8] ⓘ
pub fn chunk_at_char(&self, char_offset: u32) -> &[u8] ⓘ
pub fn chunk_at_line_break(&self, break_index: u32) -> &[u8] ⓘ
pub fn line(&self, line: u32) -> ChunkIter<'a> ⓘ
pub fn try_line(&self, line: u32) -> Option<ChunkIter<'a>>
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) -> u32
pub fn try_byte_to_char(&self, byte_offset: u32) -> Option<u32>
pub fn char_to_byte(&self, char_index: u32) -> u32
pub fn try_char_to_byte(&self, char_index: u32) -> Option<u32>
pub fn byte_to_line(&self, byte_offset: u32) -> u32
pub fn try_byte_to_line(&self, byte_offset: u32) -> Option<u32>
pub fn line_to_byte(&self, line: u32) -> u32
pub fn try_line_to_byte(&self, line: u32) -> Option<u32>
pub fn abs_line_range(&self, rel_line: u32) -> Option<(u32, u32)>
Trait Implementations§
impl<'a> Copy for TreeSlice<'a>
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