pub struct OffsetTable { /* private fields */ }Expand description
Maps UTF-8 byte offsets in one source file to UTF-16 code-unit offsets.
Implementations§
Source§impl OffsetTable
impl OffsetTable
Sourcepub fn byte_to_utf16(&self, byte_offset: usize) -> usize
pub fn byte_to_utf16(&self, byte_offset: usize) -> usize
Translate one UTF-8 byte offset (must land on a char boundary, which every tree-sitter node boundary does for valid UTF-8 source) to its UTF-16 code-unit offset from the start of the file.
Sourcepub fn translate_point(
&self,
byte_offset: usize,
column_bytes: usize,
) -> (usize, usize)
pub fn translate_point( &self, byte_offset: usize, column_bytes: usize, ) -> (usize, usize)
Translate a tree-sitter point – byte_offset from the start of the
file, column_bytes from the start of its row – into
(utf16 offset from file start, utf16 column from row start). Rows
themselves are never translated; §5.5 rows always agree.
Auto Trait Implementations§
impl Freeze for OffsetTable
impl RefUnwindSafe for OffsetTable
impl Send for OffsetTable
impl Sync for OffsetTable
impl Unpin for OffsetTable
impl UnsafeUnpin for OffsetTable
impl UnwindSafe for OffsetTable
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> 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