pub struct SourcePosition {
pub offset: usize,
pub line: usize,
pub column: usize,
}Expand description
A source position with both byte offset and line/column information.
Fields§
§offset: usizeByte offset from the start of the file.
line: usize1-based line number.
column: usize1-based column number.
Implementations§
Source§impl SourcePosition
impl SourcePosition
Sourcepub fn advance_col(self, bytes: usize) -> Self
pub fn advance_col(self, bytes: usize) -> Self
Advance by one character (non-newline).
Sourcepub fn advance_line(self, bytes: usize) -> Self
pub fn advance_line(self, bytes: usize) -> Self
Advance to the next line.
Sourcepub fn is_before(&self, other: &SourcePosition) -> bool
pub fn is_before(&self, other: &SourcePosition) -> bool
Check if this position is before another.
Sourcepub fn is_after(&self, other: &SourcePosition) -> bool
pub fn is_after(&self, other: &SourcePosition) -> bool
Check if this position is after another.
Trait Implementations§
Source§impl Clone for SourcePosition
impl Clone for SourcePosition
Source§fn clone(&self) -> SourcePosition
fn clone(&self) -> SourcePosition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SourcePosition
impl Debug for SourcePosition
Source§impl Display for SourcePosition
impl Display for SourcePosition
Source§impl Hash for SourcePosition
impl Hash for SourcePosition
Source§impl Ord for SourcePosition
impl Ord for SourcePosition
Source§fn cmp(&self, other: &SourcePosition) -> Ordering
fn cmp(&self, other: &SourcePosition) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for SourcePosition
impl PartialEq for SourcePosition
Source§impl PartialOrd for SourcePosition
impl PartialOrd for SourcePosition
impl Copy for SourcePosition
impl Eq for SourcePosition
impl StructuralPartialEq for SourcePosition
Auto Trait Implementations§
impl Freeze for SourcePosition
impl RefUnwindSafe for SourcePosition
impl Send for SourcePosition
impl Sync for SourcePosition
impl Unpin for SourcePosition
impl UnsafeUnpin for SourcePosition
impl UnwindSafe for SourcePosition
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