pub struct LineCache { /* private fields */ }Expand description
An object for efficient repeated byte offset to line conversions.
The first time a query is made for a given buffer, an index is constructed storing the line number at 256 byte intervals in the file. Subsequent queries can reuse the index.
This is expected to be a very short-lived object. If the line cache outlives any of the buffers it has been queried against, and future buffers receive the same address range, the line cache will return incorrect results (but will not crash).
Implementations§
Source§impl LineCache
impl LineCache
Sourcepub fn to_offset(&mut self, buf: &[u8], line: u32) -> usize
pub fn to_offset(&mut self, buf: &[u8], line: u32) -> usize
Map a line to a buffer index. Panics if out of range.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LineCache
impl RefUnwindSafe for LineCache
impl Send for LineCache
impl Sync for LineCache
impl Unpin for LineCache
impl UnwindSafe for LineCache
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more