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 moresource§impl<'a, T> From<LocatedSpan<&'a str, T>> for LocatedSpan<&'a str, T>
impl<'a, T> From<LocatedSpan<&'a str, T>> for LocatedSpan<&'a str, T>
source§fn from(value: LocatedSpan<&'a str, T>) -> Self
fn from(value: LocatedSpan<&'a str, T>) -> Self
source§impl<Span: PartialEq, T> PartialEq for LocatedSpan<Span, T>
impl<Span: PartialEq, T> PartialEq for LocatedSpan<Span, T>
impl<Span: Copy, T: Copy> Copy for LocatedSpan<Span, T>
Auto Trait Implementations§
impl<Span, T> Freeze for LocatedSpan<Span, T>
impl<Span, T> RefUnwindSafe for LocatedSpan<Span, T>where
Span: RefUnwindSafe,
T: RefUnwindSafe,
impl<Span, T> Send for LocatedSpan<Span, T>
impl<Span, T> Sync for LocatedSpan<Span, T>
impl<Span, T> Unpin for LocatedSpan<Span, T>
impl<Span, T> UnwindSafe for LocatedSpan<Span, T>where
Span: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)