pub struct Position {
pub offset: usize,
pub line: usize,
pub column: usize,
}Expand description
A single position.
A position encodes one half of a span, and includes the char offset, line number and column number.
Fields§
§offset: usizeThe absolute offset of this position, starting at 0 from the
beginning of the tree.
Note that this is a char offset, which lets us use it when
indexing into the original source string.
line: usizeThe line number, starting at 1.
column: usizeThe approximate column number, starting at 1.
Implementations§
Source§impl Position
impl Position
Sourcepub const fn new(offset: usize, line: usize, column: usize) -> Self
pub const fn new(offset: usize, line: usize, column: usize) -> Self
Create a new position with the given information.
offset is the absolute offset of the position, starting at 0 from
the beginning of the tree.
line is the line number, starting at 1.
column is the approximate column number, starting at 1.
Trait Implementations§
impl Copy for Position
impl Eq for Position
Source§impl Ord for Position
impl Ord for Position
1.21.0 (const: unstable) · 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 PartialOrd for Position
impl PartialOrd for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnsafeUnpin for Position
impl UnwindSafe for Position
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