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 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)
+=
operation. Read moresourceimpl Ord for Position
impl Ord for Position
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
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>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more