Type Alias arithmetic_parser::Location
source · pub type Location<T = ()> = LocatedSpan<usize, T>;
Expand description
Value with an associated code location. Unlike Spanned
, Location
does not retain a reference
to the original code span, just its start position and length.
Aliased Type§
struct Location<T = ()> {
pub extra: T,
/* private fields */
}
Fields§
§extra: T
Extra information that can be embedded by the user.
Implementations§
source§impl<T> Location<T>
impl<T> Location<T>
source§impl<Span, T> LocatedSpan<Span, T>
impl<Span, T> LocatedSpan<Span, T>
sourcepub fn location_offset(&self) -> usize
pub fn location_offset(&self) -> usize
The offset represents the position of the fragment relatively to the input of the parser. It starts at offset 0.
sourcepub fn location_line(&self) -> u32
pub fn location_line(&self) -> u32
The line number of the fragment relatively to the input of the parser. It starts at line 1.
sourcepub fn get_column(&self) -> usize
pub fn get_column(&self) -> usize
The column of the fragment start.
sourcepub fn fragment(&self) -> &Span
pub fn fragment(&self) -> &Span
The fragment that is spanned. The fragment represents a part of the input of the parser.
sourcepub fn map_extra<U>(self, map_fn: impl FnOnce(T) -> U) -> LocatedSpan<Span, U>
pub fn map_extra<U>(self, map_fn: impl FnOnce(T) -> U) -> LocatedSpan<Span, U>
Maps the extra
field of this span using the provided closure.
sourcepub fn map_fragment<U>(
self,
map_fn: impl FnOnce(Span) -> U
) -> LocatedSpan<U, T>
pub fn map_fragment<U>( self, map_fn: impl FnOnce(Span) -> U ) -> LocatedSpan<U, T>
Maps the fragment field of this span using the provided closure.
source§impl<Span: Copy, T> LocatedSpan<Span, T>
impl<Span: Copy, T> LocatedSpan<Span, T>
sourcepub fn as_ref(&self) -> LocatedSpan<Span, &T>
pub fn as_ref(&self) -> LocatedSpan<Span, &T>
Returns a copy of this span with borrowed extra
field.
sourcepub fn copy_with_extra<U>(&self, value: U) -> LocatedSpan<Span, U>
pub fn copy_with_extra<U>(&self, value: U) -> LocatedSpan<Span, U>
Copies this span with the provided extra
field.
sourcepub fn with_no_extra(&self) -> LocatedSpan<Span>
pub fn with_no_extra(&self) -> LocatedSpan<Span>
Removes extra
field from this span.
Trait Implementations§
source§impl<Span: Clone, T: Clone> Clone for LocatedSpan<Span, T>
impl<Span: Clone, T: Clone> Clone for LocatedSpan<Span, T>
source§fn clone(&self) -> LocatedSpan<Span, T>
fn clone(&self) -> LocatedSpan<Span, T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more