pub struct LineIndex { /* private fields */ }Expand description
Precomputed newline codepoint-offsets for O(log n) line lookup —
same idea as pylatexenc’s internal line-boundary cache.
Implementations§
Source§impl LineIndex
impl LineIndex
pub fn new(chars: &[char]) -> Self
Sourcepub fn with_offset(chars: &[char], offset: u32) -> Self
pub fn with_offset(chars: &[char], offset: u32) -> Self
Like Self::new, but every lineno_colno result has
offset added to its line. pos arguments stay relative to
chars as given (fragment-local), not to the offset target.
Sourcepub fn lineno_colno(&self, pos: usize) -> (u32, u32)
pub fn lineno_colno(&self, pos: usize) -> (u32, u32)
Returns (1-based line, 0-based column), both in codepoints.
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