[][src]Struct arithmetic_parser::LocatedSpan

pub struct LocatedSpan<Span, T = ()> {
    pub extra: T,
    // some fields omitted
}

Code span together with information related to where it is located in the code.

This type is similar to one from the nom_locate crate, but it has slightly different functionality. In particular, this type provides no method to access other parts of the code (which is performed in nom_locate's LocatedSpan::get_column() among other methods). As such, this allows to safely replace span info without worrying about undefined behavior.

Fields

extra: T

Extra information that can be embedded by the user.

Implementations

impl<Span, T> LocatedSpan<Span, T>[src]

pub fn location_offset(&self) -> usize[src]

The offset represents the position of the fragment relatively to the input of the parser. It starts at offset 0.

pub fn location_line(&self) -> u32[src]

The line number of the fragment relatively to the input of the parser. It starts at line 1.

pub fn get_column(&self) -> usize[src]

The column of the fragment start.

pub fn fragment(&self) -> &Span[src]

The fragment that is spanned. The fragment represents a part of the input of the parser.

pub fn map_extra<U>(self, map_fn: impl FnOnce(T) -> U) -> LocatedSpan<Span, U>[src]

Maps the extra field of this span using the provided closure.

pub fn map_fragment<U>(
    self,
    map_fn: impl FnOnce(Span) -> U
) -> LocatedSpan<U, T>
[src]

Maps the fragment field of this span using the provided closure.

impl<Span: Copy, T> LocatedSpan<Span, T>[src]

pub fn copy_with_extra<U>(&self, value: U) -> LocatedSpan<Span, U>[src]

Copies this span with the provided extra field.

pub fn with_no_extra(&self) -> LocatedSpan<Span>[src]

Removes extra field from this span.

impl<'a> LocatedSpan<&'a str, T>[src]

pub fn from_str<R>(code: &'a str, range: R) -> Self where
    InputSpan<'a>: Slice<R>, 
[src]

Creates a span from a range in the provided code. This is mostly useful for testing.

impl<'a> LocatedSpan<CodeFragment<'a>, T>[src]

pub fn from_str<R>(code: &'a str, range: R) -> Self where
    InputSpan<'a>: Slice<R>, 
[src]

Creates a span from a range in the provided code. This is mostly useful for testing.

impl<T, '_> LocatedSpan<CodeFragment<'a>, T>[src]

pub fn code_or_location(&self, default_name: &str) -> String[src]

Returns either the original code fragment (if it's retained), or a string in the form {default_name} at {line}:{column}.

Trait Implementations

impl<Span: Clone, T: Clone> Clone for LocatedSpan<Span, T>[src]

impl<Span: Copy, T: Copy> Copy for LocatedSpan<Span, T>[src]

impl<Span: Debug, T: Debug> Debug for LocatedSpan<Span, T>[src]

impl<'a, T> From<LocatedSpan<&'a str, T>> for LocatedSpan<&'a str, T>[src]

impl<'a, T> From<LocatedSpan<&'a str, T>> for MaybeSpanned<'a, T>[src]

impl<Span: PartialEq, T> PartialEq<LocatedSpan<Span, T>> for LocatedSpan<Span, T>[src]

Auto Trait Implementations

impl<Span, T> RefUnwindSafe for LocatedSpan<Span, T> where
    Span: RefUnwindSafe,
    T: RefUnwindSafe

impl<Span, T> Send for LocatedSpan<Span, T> where
    Span: Send,
    T: Send

impl<Span, T> Sync for LocatedSpan<Span, T> where
    Span: Sync,
    T: Sync

impl<Span, T> Unpin for LocatedSpan<Span, T> where
    Span: Unpin,
    T: Unpin

impl<Span, T> UnwindSafe for LocatedSpan<Span, T> where
    Span: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.