Struct nom_span::Spanned

source ·
pub struct Spanned<T> { /* private fields */ }
Expand description

You can wrap your input in this struct with Spanned::new

Implementations§

source§

impl<T> Spanned<T>

source

pub fn new(data: T, handle_utf8: bool) -> Self

source

pub fn line(&self) -> usize

Get the current line number

source

pub fn col(&self) -> usize

Get the current column number

source

pub fn byte_offset(&self) -> usize

Get the current byte offset

source

pub fn data(&self) -> &T

Get the current data in the span

Trait Implementations§

source§

impl<T> AsBytes for Spanned<T>where T: AsBytes,

source§

fn as_bytes(&self) -> &[u8]

Casts the input type to a byte slice
source§

impl<T, U> AsRef<U> for Spanned<&T>where T: ?Sized + AsRef<U>, U: ?Sized,

source§

fn as_ref(&self) -> &U

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: Clone> Clone for Spanned<T>

source§

fn clone(&self) -> Spanned<T>

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<T> Compare<T> for Spanned<T>where T: Compare<T>,

source§

fn compare(&self, t: T) -> CompareResult

Compares self to another value for equality
source§

fn compare_no_case(&self, t: T) -> CompareResult

Compares self to another value for equality independently of the case. Read more
source§

impl<T: Debug> Debug for Spanned<T>

source§

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

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

impl<T> Deref for Spanned<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> ExtendInto for Spanned<T>where T: ExtendInto,

§

type Item = <T as ExtendInto>::Item

The current input type is a sequence of that Item type. Read more
§

type Extender = <T as ExtendInto>::Extender

The type that will be produced
source§

fn new_builder(&self) -> Self::Extender

Create a new Extend of the correct type
source§

fn extend_into(&self, acc: &mut Self::Extender)

Accumulate the input into an accumulator
source§

impl<T> FindSubstring<T> for Spanned<T>where T: FindSubstring<T>,

source§

fn find_substring(&self, substr: T) -> Option<usize>

Returns the byte position of the substring if it is found
source§

impl<T, Token> FindToken<Token> for Spanned<T>where T: FindToken<Token>,

source§

fn find_token(&self, token: Token) -> bool

Returns true if self contains the token
source§

impl<T> InputIter for Spanned<T>where T: InputIter,

§

type Item = <T as InputIter>::Item

The current input type is a sequence of that Item type. Read more
§

type Iter = <T as InputIter>::Iter

An iterator over the input type, producing the item and its position for use with Slice. If we’re iterating over &str, the position corresponds to the byte index of the character
§

type IterElem = <T as InputIter>::IterElem

An iterator over the input type, producing the item
source§

fn iter_indices(&self) -> Self::Iter

Returns an iterator over the elements and their byte offsets
source§

fn iter_elements(&self) -> Self::IterElem

Returns an iterator over the elements
source§

fn position<P>(&self, predicate: P) -> Option<usize>where P: Fn(Self::Item) -> bool,

Finds the byte position of the element
source§

fn slice_index(&self, count: usize) -> Result<usize, Needed>

Get the byte offset from the element’s position in the stream
source§

impl<T> InputLength for Spanned<T>where T: InputLength,

source§

fn input_len(&self) -> usize

Calculates the input length, as indicated by its name, and the name of the trait itself
source§

impl<T> InputTake for Spanned<T>where Self: Slice<RangeFrom<usize>> + Slice<RangeTo<usize>>,

source§

fn take(&self, count: usize) -> Self

Returns a slice of count bytes. panics if count > length
source§

fn take_split(&self, count: usize) -> (Self, Self)

Split the stream at the count byte offset. panics if count > length
source§

impl<T> InputTakeAtPosition for Spanned<T>where T: InputTakeAtPosition + InputLength + InputIter, Self: Slice<RangeFrom<usize>> + Slice<RangeTo<usize>> + Clone,

§

type Item = <T as InputIter>::Item

The current input type is a sequence of that Item type. Read more
source§

fn split_at_position<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool,

Looks for the first element of the input type for which the condition returns true, and returns the input up to this position. Read more
source§

fn split_at_position1<P, E: ParseError<Self>>( &self, predicate: P, _e: ErrorKind ) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool,

Looks for the first element of the input type for which the condition returns true and returns the input up to this position. Read more
source§

fn split_at_position_complete<P, E: ParseError<Self>>( &self, predicate: P ) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool,

Looks for the first element of the input type for which the condition returns true, and returns the input up to this position. Read more
source§

fn split_at_position1_complete<P, E: ParseError<Self>>( &self, predicate: P, e: ErrorKind ) -> IResult<Self, Self, E>where P: Fn(Self::Item) -> bool,

Looks for the first element of the input type for which the condition returns true and returns the input up to this position. Read more
source§

impl<T> Offset for Spanned<T>where T: Offset,

source§

fn offset(&self, second: &Self) -> usize

Offset between the first byte of self and the first byte of the argument
source§

impl<T, R: FromStr> ParseTo<R> for Spanned<T>where T: ParseTo<R>,

source§

fn parse_to(&self) -> Option<R>

Succeeds if parse() succeeded. The byte slice implementation will first convert it to a &str, then apply the parse() function
source§

impl<T: PartialEq> PartialEq for Spanned<T>

source§

fn eq(&self, other: &Spanned<T>) -> bool

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

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

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

impl<T, R> Slice<R> for Spanned<T>where T: Slice<R> + Offset + AsBytes + Slice<RangeTo<usize>>,

source§

fn slice(&self, range: R) -> Self

Slices self according to the range argument
source§

impl<T: Copy> Copy for Spanned<T>

source§

impl<T: Eq> Eq for Spanned<T>

source§

impl<T> StructuralEq for Spanned<T>

source§

impl<T> StructuralPartialEq for Spanned<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Spanned<T>where T: RefUnwindSafe,

§

impl<T> Send for Spanned<T>where T: Send,

§

impl<T> Sync for Spanned<T>where T: Sync,

§

impl<T> Unpin for Spanned<T>where T: Unpin,

§

impl<T> UnwindSafe for Spanned<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.