pub struct Position { /* private fields */ }
Expand description
A location (line number + character position) in the input script.
Limitations
In order to keep footprint small, both line number and character position have 16-bit resolution, meaning they go up to a maximum of 65,535 lines and 65,535 characters per line.
Advancing beyond the maximum line length or maximum number of lines is not an error but has no effect.
Implementations
sourceimpl Position
impl Position
sourcepub const fn new_const(line: u16, position: u16) -> Option<Self>
👎 Deprecated since 1.6.0: use new
instead
pub const fn new_const(line: u16, position: u16) -> Option<Self>
use new
instead
Create a new Position
.
If line
is zero, then None
is returned.
If position
is zero, then it is at the beginning of a line.
Deprecated
This function is deprecated. Use new
(which panics when line
is zero) instead.
This method will be removed in the next major version.
sourceimpl Position
impl Position
sourcepub const NONE: Self = Self {
#[cfg(not(feature = "no_position"))]
line: 0,
#[cfg(not(feature = "no_position"))]
pos: 0,
}
pub const NONE: Self = Self { #[cfg(not(feature = "no_position"))] line: 0, #[cfg(not(feature = "no_position"))] pos: 0, }
A Position
representing no position.
sourcepub const START: Self = Self {
#[cfg(not(feature = "no_position"))]
line: 1,
#[cfg(not(feature = "no_position"))]
pos: 0,
}
pub const START: Self = Self { #[cfg(not(feature = "no_position"))] line: 1, #[cfg(not(feature = "no_position"))] pos: 0, }
A Position
representing the first position.
sourcepub const fn line(self) -> Option<usize>
pub const fn line(self) -> Option<usize>
Get the line number (1-based), or None
if there is no position.
sourcepub const fn position(self) -> Option<usize>
pub const fn position(self) -> Option<usize>
Get the character position (1-based), or None
if at beginning of a line.
sourcepub const fn is_beginning_of_line(self) -> bool
pub const fn is_beginning_of_line(self) -> bool
Is this Position
at the beginning of a line?
Trait Implementations
sourceimpl AddAssign<Position> for Position
impl AddAssign<Position> for Position
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the +=
operation. Read more
sourceimpl Ord for Position
impl Ord for Position
sourceimpl PartialOrd<Position> for Position
impl PartialOrd<Position> for Position
sourcefn partial_cmp(&self, other: &Position) -> Option<Ordering>
fn partial_cmp(&self, other: &Position) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Position
impl Eq for Position
impl StructuralEq for Position
impl StructuralPartialEq for Position
Auto Trait Implementations
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more