pub struct LineIndex { /* private fields */ }Expand description
Precomputed line-start offsets for O(log n) position conversion.
Implementations§
Source§impl LineIndex
impl LineIndex
Sourcepub fn offset_to_position(&self, offset: usize) -> Position
pub fn offset_to_position(&self, offset: usize) -> Position
Convert a byte offset to an LSP Position. O(log n) via binary search.
Sourcepub fn position_to_offset(&self, pos: Position) -> usize
pub fn position_to_offset(&self, pos: Position) -> usize
Convert an LSP Position to a byte offset. O(1).
Sourcepub fn span_to_range(&self, start: usize, end: usize) -> Range
pub fn span_to_range(&self, start: usize, end: usize) -> Range
Convert byte offset span to an LSP Range.
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