pub struct LineIndex { /* private fields */ }Expand description
Maps byte offsets to/from (line, column) and UTF-16 columns.
Lines and columns are 0-based. The core emits byte offsets; LSP/JS clients convert
to UTF-16 via this (the documented position-encoding footgun —
plans/01-ARCHITECTURE.md §4).
Implementations§
Source§impl LineIndex
impl LineIndex
Sourcepub fn line_col(&self, offset: u32) -> LineCol
pub fn line_col(&self, offset: u32) -> LineCol
The (line, byte-column) of a byte offset (clamped to the end of input).
Sourcepub fn utf16_col(&self, text: &str, offset: u32) -> u32
pub fn utf16_col(&self, text: &str, offset: u32) -> u32
The UTF-16 column of a byte offset on its line (LSP’s default encoding).
Sourcepub fn line_count(&self) -> u32
pub fn line_count(&self) -> u32
The number of lines.
Trait Implementations§
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