pub struct SourcePos { /* private fields */ }Expand description
Position in source code.
The position is represented by its offset, line, and column. The offset is a zero-based byte index, the line and column are one-based character indices.
The Eq, PartialEq, Ord, and PartialOrd traits are implemented in
terms of the offset. This reflects an assumption that the line and column
are derived information.
§Example
use sari::SourcePos;
let pos = SourcePos::new(69, 5, 7); // offset 69, line 5, column 7
assert_eq!(pos.offset(), 69);
assert_eq!(pos.line(), 5);
assert_eq!(pos.column(), 7);Implementations§
Source§impl SourcePos
impl SourcePos
Sourcepub fn new(offset: usize, line: usize, column: usize) -> SourcePos
pub fn new(offset: usize, line: usize, column: usize) -> SourcePos
Creates a new SourcePos with specified offset, line, and column.
§Example
use sari::SourcePos;
let pos = SourcePos::new(69, 5, 7); // offset 69, line 5, column 7
assert_eq!(pos.offset(), 69);
assert_eq!(pos.line(), 5);
assert_eq!(pos.column(), 7);Trait Implementations§
Source§impl Ord for SourcePos
impl Ord for SourcePos
Source§impl PartialOrd for SourcePos
impl PartialOrd for SourcePos
impl Copy for SourcePos
impl Eq for SourcePos
Auto Trait Implementations§
impl Freeze for SourcePos
impl RefUnwindSafe for SourcePos
impl Send for SourcePos
impl Sync for SourcePos
impl Unpin for SourcePos
impl UnwindSafe for SourcePos
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