Skip to main content

MappedSpan

Struct MappedSpan 

Source
pub struct MappedSpan<S: Span, I, F> { /* private fields */ }
Expand description

An input wrapper that maps the span type of your input into your custom span Input::map_span.

Trait Implementations§

Source§

impl<'src, S, I: BorrowInput<'src>, F> BorrowInput<'src> for MappedSpan<S, I, F>
where S: Span + Clone + 'src, S::Context: Clone + 'src, S::Offset: From<<I::Span as Span>::Offset>, F: Fn(I::Span) -> S + 'src,

Source§

unsafe fn next_ref( (cache, _): &mut Self::Cache, cursor: &mut Self::Cursor, ) -> Option<&'src Self::Token>

Borrowed version of ValueInput::next with the same safety requirements. Read more
Source§

impl<S: Clone + Span, I: Clone, F: Clone> Clone for MappedSpan<S, I, F>

Source§

fn clone(&self) -> MappedSpan<S, I, F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'src, S, I, F> ExactSizeInput<'src> for MappedSpan<S, I, F>
where I: ExactSizeInput<'src> + Input<'src>, S: Span + Clone + 'src, S::Context: Clone + 'src, S::Offset: From<<I::Span as Span>::Offset>, F: Fn(I::Span) -> S + 'src,

Source§

unsafe fn span_from( (cache, mapper): &mut Self::Cache, range: RangeFrom<&Self::Cursor>, ) -> Self::Span

Get a span from a start cursor to the end of the input. Read more
Source§

impl<'src, S, I: Input<'src>, F> Input<'src> for MappedSpan<S, I, F>
where S: Span + Clone + 'src, S::Context: Clone + 'src, S::Offset: From<<I::Span as Span>::Offset>, F: Fn(I::Span) -> S + 'src,

Source§

type Cursor = <I as Input<'src>>::Cursor

The type used to keep track of the current location in the stream. Read more
Source§

type Span = S

The type of a span on this input. Read more
Source§

type Token = <I as Input<'src>>::Token

The type of singular tokens generated by the input. Read more
Source§

type MaybeToken = <I as Input<'src>>::MaybeToken

The token type returned by Input::next_maybe, allowing abstracting over by-value and by-reference inputs. Read more
Source§

type Cache = (<I as Input<'src>>::Cache, F)

A type that contains cached or constant data pertaining to an input. Read more
Source§

fn begin(self) -> (Self::Cursor, Self::Cache)

Create an initial cursor and cache at the start of the input.
Source§

fn cursor_location(cursor: &Self::Cursor) -> usize

Return the ‘location’ associated with the given cursor. Read more
Source§

unsafe fn next_maybe( (cache, _): &mut Self::Cache, cursor: &mut Self::Cursor, ) -> Option<Self::MaybeToken>

Pull the next token, if any, from the input. Read more
Source§

unsafe fn span( (cache, mapper): &mut Self::Cache, range: Range<&Self::Cursor>, ) -> Self::Span

Create a span going from the start cursor to the end cursor (exclusive). Read more
Source§

fn with_context<S: Span>(self, context: S::Context) -> WithContext<S, Self>
where Self: Sized,

Add extra context within spans generated by this input. Read more
Source§

fn map<T, S, F>(self, eoi: S, f: F) -> MappedInput<'src, T, S, Self, F>
where Self: Sized, F: Fn(Self::MaybeToken) -> (<Self::MaybeToken as IntoMaybe<'src, Self::Token>>::Proj<T>, <Self::MaybeToken as IntoMaybe<'src, Self::Token>>::Proj<S>) + 'src, T: 'src, S: Span + 'src,

Map tokens of the input into separate token and span types, using the provided function. Read more
Source§

fn split_token_span<T, S>(self, eoi: S) -> MappedInput<'src, T, S, Self>
where Self: Input<'src, Token = (T, S), MaybeToken = &'src (T, S)> + Sized, T: 'src, S: Span + 'src,

Take an input (such as a slice) with token type (T, S) and turns it into one that produces tokens of type T and spans of type S. Read more
Source§

fn split_spanned<T, S>(self, eoi: S) -> MappedInput<'src, T, S, Self>
where Self: Input<'src, Token = S::Spanned, MaybeToken = &'src S::Spanned> + Sized, T: 'src, S: WrappingSpan<T> + 'src,

Take an input (such as a slice) with token type T where T is a spanned type, and split it into its inner value and token. Read more
Source§

fn map_span<S: Span, F>(self, map_fn: F) -> MappedSpan<S, Self, F>
where Self: Input<'src> + Sized, F: Fn(Self::Span) -> S,

Map the spans output for this input to a different output span. Read more
Source§

impl<'src, S, I: SliceInput<'src>, F> SliceInput<'src> for MappedSpan<S, I, F>
where S: Span + Clone + 'src, S::Context: Clone + 'src, S::Offset: From<<I::Span as Span>::Offset>, F: Fn(I::Span) -> S + 'src,

Source§

type Slice = <I as SliceInput<'src>>::Slice

The unsized slice type of this input. For &str it’s &str, and for [&[T]] it will be &[T].
Source§

fn full_slice((cache, _): &mut Self::Cache) -> Self::Slice

Get the full slice of the input Read more
Source§

unsafe fn slice( (cache, _): &mut Self::Cache, range: Range<&Self::Cursor>, ) -> Self::Slice

Get a slice from a start and end cursor Read more
Source§

unsafe fn slice_from( (cache, _): &mut Self::Cache, from: RangeFrom<&Self::Cursor>, ) -> Self::Slice

Get a slice from a start cursor to the end of the input Read more
Source§

impl<'src, S, I: ValueInput<'src>, F> ValueInput<'src> for MappedSpan<S, I, F>
where S: Span + Clone + 'src, S::Context: Clone + 'src, S::Offset: From<<I::Span as Span>::Offset>, F: Fn(I::Span) -> S + 'src,

Source§

unsafe fn next( (cache, _): &mut Self::Cache, cursor: &mut Self::Cursor, ) -> Option<Self::Token>

Get the next cursor from the provided one, and the next token if it exists Read more
Source§

impl<S: Copy + Span, I: Copy, F: Copy> Copy for MappedSpan<S, I, F>

Source§

impl<'src, S, I, F> StrInput<'src> for MappedSpan<S, I, F>
where I: StrInput<'src>, I::Token: Char, S: Span + Clone + 'src, S::Context: Clone + 'src, S::Offset: From<<I::Span as Span>::Offset>, F: Fn(I::Span) -> S + 'src,

Auto Trait Implementations§

§

impl<S, I, F> Freeze for MappedSpan<S, I, F>
where I: Freeze, F: Freeze,

§

impl<S, I, F> RefUnwindSafe for MappedSpan<S, I, F>

§

impl<S, I, F> Send for MappedSpan<S, I, F>
where I: Send, F: Send, S: Send,

§

impl<S, I, F> Sync for MappedSpan<S, I, F>
where I: Sync, F: Sync, S: Sync,

§

impl<S, I, F> Unpin for MappedSpan<S, I, F>
where I: Unpin, F: Unpin, S: Unpin,

§

impl<S, I, F> UnsafeUnpin for MappedSpan<S, I, F>
where I: UnsafeUnpin, F: UnsafeUnpin,

§

impl<S, I, F> UnwindSafe for MappedSpan<S, I, F>
where I: UnwindSafe, F: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> S::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,