Skip to main content

Function

Struct Function 

Source
pub struct Function<F, I: ?Sized, C> { /* private fields */ }
Expand description

A parser for function function.

Implementations§

Source§

impl<F, I: ?Sized, C> Function<F, I, C>

Source

pub fn new(f: F) -> Self

Creates a new instance.

Trait Implementations§

Source§

impl<F: Clone, I: Clone + ?Sized, C: Clone> Clone for Function<F, I, C>

Source§

fn clone(&self) -> Function<F, I, C>

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<F: Debug, I: Debug + ?Sized, C: Debug> Debug for Function<F, I, C>

Source§

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

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

impl<F, I, T, C> IterableParser<I> for Function<F, I, C>
where F: FnMut(Pin<&mut I>, &mut Context<'_>, &mut C) -> PolledResult<Option<T>, I>, I: Positioned + ?Sized, C: Default,

Source§

type Item = T

The type for items of input stream.
Source§

type State = C

The internal state used in poll_parse_next. Read more
Source§

fn poll_parse_next( &mut self, input: Pin<&mut I>, cx: &mut Context<'_>, state: &mut Self::State, ) -> PolledResult<Option<Self::Item>, I>

Takes an input, returns a Status of next output or None.
Source§

fn size_hint(&self) -> (usize, Option<usize>)

The estimated size of returned stream.
Source§

impl<F, I, O, C> Parser<I> for Function<F, I, C>
where F: FnMut(Pin<&mut I>, &mut Context<'_>, &mut C) -> PolledResult<O, I>, I: Positioned + ?Sized, C: Default,

Source§

type Output = O

The output type for the parser.
Source§

type State = C

The internal state used in poll_parse. Read more
Source§

fn poll_parse( &mut self, input: Pin<&mut I>, cx: &mut Context<'_>, state: &mut Self::State, ) -> PolledResult<Self::Output, I>

Parses the input, give an Status.
Source§

impl<F: PartialEq, I: PartialEq + ?Sized, C: PartialEq> PartialEq for Function<F, I, C>

Source§

fn eq(&self, other: &Function<F, I, C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: Eq, I: Eq + ?Sized, C: Eq> Eq for Function<F, I, C>

Source§

impl<F, I: ?Sized, C> StructuralPartialEq for Function<F, I, C>

Auto Trait Implementations§

§

impl<F, I, C> Freeze for Function<F, I, C>
where F: Freeze, I: ?Sized,

§

impl<F, I, C> RefUnwindSafe for Function<F, I, C>
where F: RefUnwindSafe, I: ?Sized,

§

impl<F, I, C> Send for Function<F, I, C>
where F: Send, I: ?Sized,

§

impl<F, I, C> Sync for Function<F, I, C>
where F: Sync, I: ?Sized,

§

impl<F, I, C> Unpin for Function<F, I, C>
where F: Unpin, I: ?Sized,

§

impl<F, I, C> UnsafeUnpin for Function<F, I, C>
where F: UnsafeUnpin, I: ?Sized,

§

impl<F, I, C> UnwindSafe for Function<F, I, C>
where F: UnwindSafe, I: ?Sized,

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<P, I> IterableParserExt<I> for P
where P: IterableParser<I> + ?Sized, I: Positioned + ?Sized,

Source§

fn parse_iterable<'a, 'b>( &'a mut self, input: &'b mut I, ) -> IterableParserStream<'a, 'b, Self, I, Self::State>
where I: Unpin,

Returns a TryStream by invoking poll_parse_next.
Source§

fn boxed<'a>( self, ) -> Box<dyn IterableParser<I, Item = Self::Item, State = Self::State> + 'a>
where Self: Sized + 'a,

Available on crate feature alloc only.
Wraps the parser into a Box.
Source§

fn no_state(self) -> NoState<Self, Self::State>
where Self: Sized,

Merges State into the parser itself.
Source§

fn left<R>(self) -> Either<Self, R>
where Self: Sized, R: IterableParser<I, Item = Self::Item>,

Wraps the parser into a Either to merge multiple types of parsers.
Source§

fn right<L>(self) -> Either<L, Self>
where Self: Sized, L: IterableParser<I, Item = Self::Item>,

Wraps the parser into a Either to merge multiple types of parsers.
Source§

fn complete(self) -> Skip<Self, Eof<I>>
where Self: Sized,

Parses the input completedly. Read more
Source§

fn chain<P>(self, p: P) -> (Self, P)
where Self: Sized, P: IterableParser<I, Item = Self::Item>,

Chains two iterable parsers and parses items in sequence.
Source§

fn or<P>(self, p: P) -> Or<Self, P>
where I: Input, Self: Sized, P: IterableParser<I, Item = Self::Item>,

Tries another parser if the first parser failed parsing.
Source§

fn opt(self) -> Opt<Self>
where Self: Sized, I: Input,

Returns Some if parsing is succeeded.
Source§

fn skip<P>(self, p: P) -> Skip<Self, P>
where Self: Sized, P: Parser<I>,

Parses with self, then skips p.
Source§

fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R>
where Self: Sized, L: Parser<I>, R: Parser<I>,

Parses with self between left and right.
Source§

fn discard(self) -> Discard<Self>
where Self: Sized,

Returns a Parser parses all items and returns ().
Source§

fn count(self) -> Count<Self>
where Self: Sized,

Returns a Parser outputs usize by couting up all items.
Source§

fn collect<E: Default + Extend<Self::Item>>(self) -> Collect<Self, E>
where Self: Sized,

Returns a Parser by collecting all the outputs.
Source§

fn first(self) -> Nth<Self>
where Self: Sized,

Consumes all outputs, returns the first element. Read more
Source§

fn last(self) -> Last<Self>
where Self: Sized,

Consumes all outputs, returns the last element. Read more
Source§

fn nth(self, n: usize) -> Nth<Self>
where Self: Sized,

Consumes all outputs, returns the nth element. Read more
Source§

fn fill<const N: usize>(self, start: usize) -> Indices<Self, N>
where Self: Sized,

Consumes all outputs, returns N elements from index start. Read more
Source§

fn indices<const N: usize>(self, ns: [usize; N]) -> Indices<Self, N>
where Self: Sized,

Consumes all outputs, returns multiple elements specified by ns, an ascending ordered array of indices. Read more
Source§

fn flat_repeat<R>(self, range: R) -> FlatRepeat<Self, R>
where Self: Sized, I: Input, R: RangeBounds<usize>,

Repeats the iterable parser like ParserExt::repeat, and flattens into one iterable parser.
Source§

fn flat_times(self, n: usize) -> FlatTimes<Self>
where Self: Sized,

Repeats the iterable parser like ParserExt::times, and flattens into one iterable parser.
Source§

fn flat_sep_by<P, R>(self, sep: P, range: R) -> FlatSepBy<Self, P, R>
where Self: Sized, I: Input, P: Parser<I>, R: RangeBounds<usize>,

Repeats the iterable parser with separaters like ParserExt::sep_by, and flattens into one iterable parser.
Source§

fn flat_sep_by_end<P, R>(self, sep: P, range: R) -> FlatSepByEnd<Self, P, R>
where Self: Sized, I: Input, P: Parser<I>, R: RangeBounds<usize>,

Repeats the iterable parser with separaters like ParserExt::sep_by_end, and flattens into one iterable parser.
Source§

fn flat_sep_by_times<P>(self, sep: P, count: usize) -> FlatSepByTimes<Self, P>
where Self: Sized, P: Parser<I>,

Repeats the iterable parser with separaters like ParserExt::sep_by_times, and flattens into one iterable parser.
Source§

fn flat_sep_by_end_times<P>( self, sep: P, count: usize, ) -> FlatSepByEndTimes<Self, P>
where Self: Sized, I: Input, P: Parser<I>,

Repeats the iterable parser with separaters like ParserExt::sep_by_end_times, and flattens into one iterable parser.
Source§

fn flat_until<P>(self, end: P) -> FlatUntil<Self, P>
where Self: Sized, I: Input, P: Parser<I>,

Repeats the iterable parser until end like ParserExt::until, and flattens into one iterable parser.
Source§

fn map<F, O>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> O,

Converts an output value into another type.
Source§

fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> Result<O, E>, E: Into<Expects>,

Converts an output value into another type.
Source§

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Returns current iteration count with elements. Read more
Source§

fn flatten(self) -> Flatten<Self>
where Self: Sized, Self::Item: IntoIterator,

Flattens iteratable items.
Source§

fn filter<F>(self, f: F) -> Filter<Self, F>
where Self: Sized, F: FnMut(&Self::Item) -> bool,

Only returns items matches the condition.
Source§

fn fold<Q, F>(self, init: Q, f: F) -> Fold<Self, Q, F>
where Self: Sized, Q: Parser<I>, F: FnMut(Q::Output, Self::Item) -> Q::Output,

Folds items into an accumulator by repeatedly applying a function.
Source§

fn try_fold<Q, F, E>(self, init: Q, f: F) -> TryFold<Self, Q, F>
where Self: Sized, Q: Parser<I>, F: FnMut(Q::Output, Self::Item) -> Result<Q::Output, E>, E: Into<Expects>,

Tries to fold items into an accumulator by repeatedly applying a failable function.
Source§

fn reduce<F>(self, f: F) -> Reduce<Self, F>
where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item,

Reduces items into a item by repeatedly applying a function.
Source§

fn try_reduce<F, E>(self, f: F) -> TryReduce<Self, F>
where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Result<Self::Item, E>, E: Into<Expects>,

Tries to reduce items into a item by repeatedly applying a failable function.
Source§

fn scan<Q, F, T>(self, init: Q, f: F) -> Scan<Self, Q, F>
where Self: Sized, Q: Parser<I>, F: FnMut(&mut Q::Output, Self::Item) -> Option<T>,

Holds internal state, applies the function item by item and returns the output (if it is Some).
Source§

fn try_scan<Q, F, T, E>(self, init: Q, f: F) -> TryScan<Self, Q, F>
where Self: Sized, Q: Parser<I>, F: FnMut(&mut Q::Output, Self::Item) -> Result<Option<T>, E>, E: Into<Expects>,

Holds internal state, applies the failable function item by item and tries to return the output (if it is Some).
Source§

impl<P, I> ParserExt<I> for P
where P: Parser<I>, I: Positioned + ?Sized,

Source§

fn parse<'a, 'b>( &'a mut self, input: &'b mut I, ) -> ParseFuture<'a, 'b, Self, I, Self::State>
where I: Unpin,

An asynchronous version of poll_parse, which returns a Future.
Source§

fn boxed<'a>( self, ) -> Box<dyn Parser<I, Output = Self::Output, State = Self::State> + 'a>
where Self: Sized + 'a,

Available on crate feature alloc only.
Wraps the parser into a Box.
Source§

fn no_state(self) -> NoState<Self, Self::State>
where Self: Sized,

Merges State into parser itself.
Source§

fn left<R>(self) -> Either<Self, R>
where Self: Sized, R: Parser<I, Output = Self::Output>,

Wraps the parser into a Either to merge multiple types of parsers.
Source§

fn right<L>(self) -> Either<L, Self>
where Self: Sized, L: Parser<I, Output = Self::Output>,

Wraps the parser into a Either to merge multiple types of parsers.
Source§

fn complete(self) -> Skip<Self, Eof<I>>
where Self: Sized,

Parses the input completedly. Read more
Source§

fn with_position(self) -> WithPosition<Self>
where Self: Sized,

Returns the position of parsed tokens with an output.
Source§

fn peek(self) -> Peek<Self>
where Self: Sized, I: Input,

Returns a parse result without consuming input.
Source§

fn fail(self) -> Fail<Self>
where Self: Sized, I: Input,

Succeeds if the parser failed parsing. Never consumes input.
Source§

fn and<P>(self, p: P) -> (Self, P)
where Self: Sized, P: Parser<I>,

Parses with self, and then with p.
Source§

fn skip<P>(self, p: P) -> Skip<Self, P>
where Self: Sized, P: Parser<I>,

Parses with self, then skips p.
Source§

fn prefix<P>(self, p: P) -> Prefix<Self, P>
where Self: Sized,

Parses with p prefixed by self.
Source§

fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R>
where Self: Sized, L: Parser<I>, R: Parser<I>,

Parses with self between left and right.
Source§

fn or<P>(self, other: P) -> Or<Self, P>
where Self: Sized, I: Input, P: Parser<I, Output = Self::Output>,

Tries another parser if the parser failed parsing.
Source§

fn opt(self) -> Opt<Self>
where Self: Sized, I: Input,

Returns Some if parsing is succeeded.
Source§

fn once(self) -> Times<Self>
where Self: Sized, I: Positioned,

Returns a IterableParser by wrapping the parser to return output exactly once. Read more
Source§

fn times(self, n: usize) -> Times<Self>
where Self: Sized, I: Positioned,

Returns a IterableParser by repeating the parser exactly n times.
Source§

fn sep_by_times<P, R>(self, sep: P, count: usize) -> SepByTimes<Self, P>
where Self: Sized, P: Parser<I>,

Returns a fixed-size IterableParser of the parser separated by sep.
Source§

fn sep_by_end_times<P, R>(self, sep: P, count: usize) -> SepByEndTimes<Self, P>
where Self: Sized, I: Input, P: Parser<I>,

Returns a fixed-size IterableParser of the parser separated by sep (trailing separater is allowed).
Source§

fn repeat<R>(self, range: R) -> Repeat<Self, R>
where Self: Sized, R: RangeBounds<usize>, I: Input,

Returns a IterableParser by repeating the parser while succeeding.
Source§

fn sep_by<P, R>(self, sep: P, range: R) -> SepBy<Self, P, R>
where Self: Sized, P: Parser<I>, R: RangeBounds<usize>, I: Input,

Returns a IterableParser of the parser separated by sep.
Source§

fn sep_by_end<P, R>(self, sep: P, range: R) -> SepByEnd<Self, P, R>
where Self: Sized, P: Parser<I>, R: RangeBounds<usize>, I: Input,

Returns a IterableParser of the parser separated by sep (trailing separater is allowed).
Source§

fn then<F, Q>(self, f: F) -> Then<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> Q,

Parses with self, passes output to the function f and parses with a returned Parser or IterableParser.
Source§

fn try_then<F, Q, E>(self, f: F) -> TryThen<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> Result<Q, E>, E: Into<Expects>,

Parses with self, passes output to the failable function f and parses with a returned Parser or IterableParser.
Source§

fn until<P>(self, end: P) -> Until<Self, P>
where Self: Sized, P: Parser<I>, I: Input,

Returns a IterableParser by repeating the parser until the parser end succeeds.
Source§

fn discard(self) -> Discard<Self>
where Self: Sized,

Discards the parse results.
Source§

fn map<F, O>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> O,

Converts an output value into another type.
Source§

fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> Result<O, E>, E: Into<Expects>,

Converts an output value into another type with a failable function.
Source§

fn satisfy<F, O>(self, f: F) -> Satisfy<Self, F>
where Self: Sized, F: FnMut(&Self::Output) -> bool,

Checks an output value with the function.
Source§

fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: FnMut(Expects) -> Expects, E: Into<Expects>,

Modifies expected values.
Source§

fn expect<E: Into<Expects>>(self, expected: E) -> Expect<Self>
where Self: Sized, I::Ok: Clone,

Overrides expected values.
Source§

fn spanned(self) -> Spanned<Self>
where Self: Sized,

Overrides the error position by the span of the parse.
Source§

fn exclusive<E: Into<Expects>>(self, expected: E) -> Exclusive<Self>
where Self: Sized, I::Ok: Clone,

Overrides parsing errors as “exclusive”.
Source§

fn rewindable(self) -> Rewindable<Self>
where Self: Sized,

Modifies “exclusive” errors as rewindable.
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.