pub struct Function<F, I: ?Sized, C> { /* private fields */ }Expand description
A parser for function function.
Implementations§
Trait Implementations§
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,
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 State = C
type State = C
The internal state used in
poll_parse_next. Read moreSource§fn poll_parse_next(
&mut self,
input: Pin<&mut I>,
cx: &mut Context<'_>,
state: &mut Self::State,
) -> PolledResult<Option<Self::Item>, I>
fn poll_parse_next( &mut self, input: Pin<&mut I>, cx: &mut Context<'_>, state: &mut Self::State, ) -> PolledResult<Option<Self::Item>, I>
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,
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§impl<F: PartialEq, I: PartialEq + ?Sized, C: PartialEq> PartialEq for Function<F, I, C>
impl<F: PartialEq, I: PartialEq + ?Sized, C: PartialEq> PartialEq for Function<F, I, C>
impl<F: Eq, I: Eq + ?Sized, C: Eq> Eq for Function<F, I, C>
impl<F, I: ?Sized, C> StructuralPartialEq for Function<F, I, C>
Auto Trait Implementations§
impl<F, I, C> Freeze for Function<F, I, C>
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>
impl<F, I, C> Sync for Function<F, I, C>
impl<F, I, C> Unpin for Function<F, I, C>
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> 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<P, I> IterableParserExt<I> for P
impl<P, I> IterableParserExt<I> for P
Source§fn parse_iterable<'a, 'b>(
&'a mut self,
input: &'b mut I,
) -> IterableParserStream<'a, 'b, Self, I, Self::State>where
I: Unpin,
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,
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,
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> ⓘ
fn left<R>(self) -> Either<Self, R> ⓘ
Wraps the parser into a
Either to merge multiple types of parsers.Source§fn right<L>(self) -> Either<L, Self> ⓘ
fn right<L>(self) -> Either<L, Self> ⓘ
Wraps the parser into a
Either to merge multiple types of parsers.Source§fn complete(self) -> Skip<Self, Eof<I>> ⓘwhere
Self: Sized,
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) ⓘ
fn chain<P>(self, p: P) -> (Self, P) ⓘ
Chains two iterable parsers and parses items in sequence.
Source§fn or<P>(self, p: P) -> Or<Self, P> ⓘ
fn or<P>(self, p: P) -> Or<Self, P> ⓘ
Tries another parser if the first parser failed parsing.
Source§fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R> ⓘ
fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R> ⓘ
Parses with
self between left and right.Source§fn discard(self) -> Discard<Self> ⓘwhere
Self: Sized,
fn discard(self) -> Discard<Self> ⓘwhere
Self: Sized,
Returns a
Parser parses all items and returns ().Source§fn collect<E: Default + Extend<Self::Item>>(self) -> Collect<Self, E> ⓘwhere
Self: Sized,
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,
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,
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,
fn nth(self, n: usize) -> Nth<Self> ⓘwhere
Self: Sized,
Consumes all outputs, returns the
nth element. Read moreSource§fn indices<const N: usize>(self, ns: [usize; N]) -> Indices<Self, N> ⓘwhere
Self: Sized,
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 moreSource§fn flat_repeat<R>(self, range: R) -> FlatRepeat<Self, R> ⓘ
fn flat_repeat<R>(self, range: R) -> FlatRepeat<Self, R> ⓘ
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,
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> ⓘ
fn flat_sep_by<P, R>(self, sep: P, range: R) -> FlatSepBy<Self, P, R> ⓘ
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> ⓘ
fn flat_sep_by_end<P, R>(self, sep: P, range: R) -> FlatSepByEnd<Self, P, R> ⓘ
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> ⓘ
fn flat_sep_by_times<P>(self, sep: P, count: usize) -> FlatSepByTimes<Self, P> ⓘ
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> ⓘ
fn flat_sep_by_end_times<P>( self, sep: P, count: usize, ) -> FlatSepByEndTimes<Self, P> ⓘ
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> ⓘ
fn flat_until<P>(self, end: P) -> FlatUntil<Self, P> ⓘ
Repeats the iterable parser until
end like ParserExt::until, and flattens into one
iterable parser.Source§fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F> ⓘ
fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F> ⓘ
Converts an output value into another type.
Source§fn enumerate(self) -> Enumerate<Self> ⓘwhere
Self: Sized,
fn enumerate(self) -> Enumerate<Self> ⓘwhere
Self: Sized,
Returns current iteration count with elements. Read more
Source§fn fold<Q, F>(self, init: Q, f: F) -> Fold<Self, Q, F> ⓘ
fn fold<Q, F>(self, init: Q, f: F) -> Fold<Self, Q, F> ⓘ
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> ⓘ
fn try_fold<Q, F, E>(self, init: Q, f: F) -> TryFold<Self, Q, F> ⓘ
Tries to fold items into an accumulator by repeatedly applying a failable function.
Source§fn reduce<F>(self, f: F) -> Reduce<Self, F> ⓘ
fn reduce<F>(self, f: F) -> Reduce<Self, F> ⓘ
Reduces items into a item by repeatedly applying a function.
Source§fn try_reduce<F, E>(self, f: F) -> TryReduce<Self, F> ⓘ
fn try_reduce<F, E>(self, f: F) -> TryReduce<Self, F> ⓘ
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> ⓘ
fn scan<Q, F, T>(self, init: Q, f: F) -> Scan<Self, Q, F> ⓘ
Holds internal state, applies the function item by item and returns the output (if it is
Some).Source§impl<P, I> ParserExt<I> for P
impl<P, I> ParserExt<I> for P
Source§fn parse<'a, 'b>(
&'a mut self,
input: &'b mut I,
) -> ParseFuture<'a, 'b, Self, I, Self::State>where
I: Unpin,
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,
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,
fn no_state(self) -> NoState<Self, Self::State>where
Self: Sized,
Merges
State into parser itself.Source§fn left<R>(self) -> Either<Self, R> ⓘ
fn left<R>(self) -> Either<Self, R> ⓘ
Wraps the parser into a
Either to merge multiple types of parsers.Source§fn right<L>(self) -> Either<L, Self> ⓘ
fn right<L>(self) -> Either<L, Self> ⓘ
Wraps the parser into a
Either to merge multiple types of parsers.Source§fn complete(self) -> Skip<Self, Eof<I>> ⓘwhere
Self: Sized,
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,
fn with_position(self) -> WithPosition<Self> ⓘwhere
Self: Sized,
Returns the position of parsed tokens with an output.
Source§fn prefix<P>(self, p: P) -> Prefix<Self, P> ⓘwhere
Self: Sized,
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> ⓘ
fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R> ⓘ
Parses with
self between left and right.Source§fn once(self) -> Times<Self> ⓘwhere
Self: Sized,
I: Positioned,
fn once(self) -> Times<Self> ⓘwhere
Self: Sized,
I: Positioned,
Returns a
IterableParser by wrapping the parser to return output exactly once. Read moreSource§fn times(self, n: usize) -> Times<Self> ⓘwhere
Self: Sized,
I: Positioned,
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> ⓘ
fn sep_by_times<P, R>(self, sep: P, count: usize) -> SepByTimes<Self, P> ⓘ
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> ⓘ
fn sep_by_end_times<P, R>(self, sep: P, count: usize) -> SepByEndTimes<Self, P> ⓘ
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> ⓘ
fn repeat<R>(self, range: R) -> Repeat<Self, R> ⓘ
Returns a
IterableParser by repeating the parser while succeeding.Source§fn sep_by<P, R>(self, sep: P, range: R) -> SepBy<Self, P, R> ⓘ
fn sep_by<P, R>(self, sep: P, range: R) -> SepBy<Self, P, R> ⓘ
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> ⓘ
fn sep_by_end<P, R>(self, sep: P, range: R) -> SepByEnd<Self, P, R> ⓘ
Returns a
IterableParser of the parser separated by sep (trailing separater is
allowed).Source§fn then<F, Q>(self, f: F) -> Then<Self, F> ⓘ
fn then<F, Q>(self, f: F) -> Then<Self, F> ⓘ
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> ⓘ
fn try_then<F, Q, E>(self, f: F) -> TryThen<Self, F> ⓘ
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> ⓘ
fn until<P>(self, end: P) -> Until<Self, P> ⓘ
Returns a
IterableParser by repeating the parser until the parser end succeeds.Source§fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F> ⓘ
fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F> ⓘ
Converts an output value into another type with a failable function.
Source§fn spanned(self) -> Spanned<Self> ⓘwhere
Self: Sized,
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> ⓘ
fn exclusive<E: Into<Expects>>(self, expected: E) -> Exclusive<Self> ⓘ
Overrides parsing errors as “exclusive”.
Source§fn rewindable(self) -> Rewindable<Self> ⓘwhere
Self: Sized,
fn rewindable(self) -> Rewindable<Self> ⓘwhere
Self: Sized,
Modifies “exclusive” errors as rewindable.