pub struct LineMap { /* private fields */ }Expand description
Line map for efficient offset <-> position conversion. Stores the starting offset of each line.
Implementations§
Source§impl LineMap
impl LineMap
Sourcepub fn offset_to_position(&self, offset: u32, source: &str) -> Position
pub fn offset_to_position(&self, offset: u32, source: &str) -> Position
Convert a byte offset to a Position (line, character). Character is counted in UTF-16 code units for LSP compatibility.
Sourcepub fn position_to_offset(
&self,
position: Position,
source: &str,
) -> Option<u32>
pub fn position_to_offset( &self, position: Position, source: &str, ) -> Option<u32>
Convert a Position (line, character) to a byte offset.
Sourcepub const fn line_count(&self) -> usize
pub const fn line_count(&self) -> usize
Get the number of lines.
Sourcepub fn line_start(&self, line: usize) -> Option<u32>
pub fn line_start(&self, line: usize) -> Option<u32>
Get the starting offset of a line.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LineMap
impl RefUnwindSafe for LineMap
impl Send for LineMap
impl Sync for LineMap
impl Unpin for LineMap
impl UnsafeUnpin for LineMap
impl UnwindSafe for LineMap
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