pub struct PosTbl { /* private fields */ }
Expand description
A table of line and column positions for a source string.
Implementations§
Source§impl PosTbl
impl PosTbl
Sourcepub fn new(chars: Vec<LineColPos>) -> Self
pub fn new(chars: Vec<LineColPos>) -> Self
Creates a new line and column position table.
Sourcepub fn generate(src: impl Iterator<Item = char>) -> Self
pub fn generate(src: impl Iterator<Item = char>) -> Self
Generates a line and column position table from a source string.
Sourcepub fn get(&self, idx: usize) -> Option<LineColPos>
pub fn get(&self, idx: usize) -> Option<LineColPos>
Gets the line and column position for a given byte index.
Sourcepub fn get_srcpos(&self, idx: usize) -> Option<SrcPos>
pub fn get_srcpos(&self, idx: usize) -> Option<SrcPos>
Gets the source position for a given byte index.
Sourcepub fn expect_srcpos(&self, idx: usize) -> SrcPos
pub fn expect_srcpos(&self, idx: usize) -> SrcPos
Gets the source position for a given byte index, panicking if out of bounds.
Sourcepub fn expect_end(&self) -> SrcPos
pub fn expect_end(&self) -> SrcPos
Gets the source position for the end of the source string, panicking if the source string is empty.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PosTbl
impl RefUnwindSafe for PosTbl
impl Send for PosTbl
impl Sync for PosTbl
impl Unpin for PosTbl
impl UnwindSafe for PosTbl
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