Struct minparser::Position

source ·
pub struct Position<FILE = ()> { /* private fields */ }
Expand description

A position.

Characters in a text file can be organizes in a virtual grid in order to easily find characters or parsing errors inside the file. Each file can be divided in multiple lines separated by line feed (U+000A) or carriage return + line feed (U+000D + U+000A).

To find a character then you need just the index of the line containing it (the first line has index 0) and the character index inside thai line (also called the column).

Type F is any type that can be used to identify a text file, for example a String, a Path or a custom type.

Implementations§

source§

impl<F> Position<F>

source

pub fn new_file(file: F, line: u32, column: u32) -> Self

Create a new Position at specified file, line and column indices

source

pub fn new_file_zero(file: F) -> Self

Create a new Position with line=0 and column=0

source

pub fn file(&self) -> &F

Get the file identifier

source

pub fn line(&self) -> u32

Get the line number

source

pub fn column(&self) -> u32

Get the column number

source

pub fn make_ref<'a>(&'a self) -> Position<&'a F>

Converts it to a reference

source§

impl<F> Position<F>
where F: Default,

source

pub fn new(line: u32, column: u32) -> Self

Like Position::new_file but with file argument set to F::default()

source

pub fn new_zero() -> Self

Like Position::new_file_zero but with file argument set to F::default()

Trait Implementations§

source§

impl<FILE: Clone> Clone for Position<FILE>

source§

fn clone(&self) -> Position<FILE>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<FILE: Debug> Debug for Position<FILE>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<FILE: PartialEq> PartialEq for Position<FILE>

source§

fn eq(&self, other: &Position<FILE>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<FILE: Copy> Copy for Position<FILE>

source§

impl<FILE: Eq> Eq for Position<FILE>

source§

impl<FILE> StructuralPartialEq for Position<FILE>

Auto Trait Implementations§

§

impl<FILE> Freeze for Position<FILE>
where FILE: Freeze,

§

impl<FILE> RefUnwindSafe for Position<FILE>
where FILE: RefUnwindSafe,

§

impl<FILE> Send for Position<FILE>
where FILE: Send,

§

impl<FILE> Sync for Position<FILE>
where FILE: Sync,

§

impl<FILE> Unpin for Position<FILE>
where FILE: Unpin,

§

impl<FILE> UnwindSafe for Position<FILE>
where FILE: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.