Struct arithmetic_parser::LocatedSpan
source · pub struct LocatedSpan<Span, T = ()> {
pub extra: T,
/* private fields */
}
Expand description
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§
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.
source§impl<'a> LocatedSpan<&'a str, ()>
impl<'a> LocatedSpan<&'a str, ()>
source§impl LocatedSpan<usize, ()>
impl LocatedSpan<usize, ()>
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