pub struct LineIndex { /* private fields */ }Expand description
Precomputed line, character, and UTF-16 offset tables for a source string.
Offsets passed to lookup methods are clamped to the source length. Returned line and column coordinates are always valid 1-based values.
Implementations§
Source§impl LineIndex
impl LineIndex
Sourcepub fn line_col(&self, offset: TextSize) -> ByteLineCol
pub fn line_col(&self, offset: TextSize) -> ByteLineCol
Maps a byte offset to a 1-based line and byte column, clamping past EOF.
Sourcepub fn char_line_col(&self, offset: TextSize) -> CharLineCol
pub fn char_line_col(&self, offset: TextSize) -> CharLineCol
Maps a byte offset to a 1-based line and Unicode scalar column.
Non-UTF-8-boundary offsets snap to the previous character boundary.
Sourcepub fn utf16_col(&self, line: LineNumber, byte_col: ByteColumn) -> Utf16Offset
pub fn utf16_col(&self, line: LineNumber, byte_col: ByteColumn) -> Utf16Offset
Returns the UTF-16 code-unit offset from the start of line to byte_col.
Both coordinates must be valid 1-based values; zero cannot be represented
by LineNumber or ByteColumn.
Sourcepub fn utf16_range(&self, range: TextRange) -> (Utf16Offset, Utf16Offset)
pub fn utf16_range(&self, range: TextRange) -> (Utf16Offset, Utf16Offset)
Maps a byte range to UTF-16 start/end offsets, clamping to source bounds.
Trait Implementations§
impl Eq for LineIndex
impl StructuralPartialEq for LineIndex
Auto Trait Implementations§
impl Freeze for LineIndex
impl RefUnwindSafe for LineIndex
impl Send for LineIndex
impl Sync for LineIndex
impl Unpin for LineIndex
impl UnsafeUnpin for LineIndex
impl UnwindSafe for LineIndex
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