pub struct Iterate<F, I, P> { /* private fields */ }
Trait Implementations
sourceimpl<'s, 'a, P, Q, I, J, F> Parser<I> for Iterate<F, J, P> where
P: FnMut(&J::Item, &mut I) -> Q,
Q: Parser<I>,
I: Stream,
J: IntoIterator + Clone,
F: Extend<Q::Output> + Default,
impl<'s, 'a, P, Q, I, J, F> Parser<I> for Iterate<F, J, P> where
P: FnMut(&J::Item, &mut I) -> Q,
Q: Parser<I>,
I: Stream,
J: IntoIterator + Clone,
F: Extend<Q::Output> + Default,
type Output = F
type Output = F
The type which is returned if the parser is successful.
type PartialState = (Option<(J::IntoIter, Option<J::Item>)>, bool, F, Q::PartialState)
type PartialState = (Option<(J::IntoIter, Option<J::Item>)>, bool, F, Q::PartialState)
Determines the state necessary to resume parsing after more input is supplied. Read more
sourcefn parse(
&mut self,
input: Input
) -> Result<(Self::Output, Input), <Input as StreamOnce>::Error>
fn parse(
&mut self,
input: Input
) -> Result<(Self::Output, Input), <Input as StreamOnce>::Error>
Entry point of the parser. Takes some input and tries to parse it. Read more
sourcefn parse_with_state(
&mut self,
input: &mut Input,
state: &mut Self::PartialState
) -> Result<Self::Output, <Input as StreamOnce>::Error>
fn parse_with_state(
&mut self,
input: &mut Input,
state: &mut Self::PartialState
) -> Result<Self::Output, <Input as StreamOnce>::Error>
Entry point of the parser when using partial parsing. Takes some input and tries to parse it. Read more
sourcefn parse_stream(
&mut self,
input: &mut Input
) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>
fn parse_stream(
&mut self,
input: &mut Input
) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>
Parses using the stream input
by calling Stream::uncons
one or more times. Read more
sourcefn parse_lazy(
&mut self,
input: &mut Input
) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>
fn parse_lazy(
&mut self,
input: &mut Input
) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>
Parses using the stream input
by calling Stream::uncons
one or more times. Read more
sourcefn add_error(&mut self, _error: &mut Tracked<<Input as StreamOnce>::Error>)
fn add_error(&mut self, _error: &mut Tracked<<Input as StreamOnce>::Error>)
Adds the first error that would normally be returned by this parser if it failed with an
PeekErr
result. Read more
sourcefn parse_stream_partial(
&mut self,
input: &mut Input,
state: &mut Self::PartialState
) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>
fn parse_stream_partial(
&mut self,
input: &mut Input,
state: &mut Self::PartialState
) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>
Like parse_stream
but supports partial parsing.
sourcefn by_ref(&mut self) -> &mut Self where
Self: Sized,
fn by_ref(&mut self) -> &mut Self where
Self: Sized,
Borrows a parser instead of consuming it. Read more
sourcefn with<P2>(self, p: P2) -> With<Self, P2> where
Self: Sized,
P2: Parser<Input>,
fn with<P2>(self, p: P2) -> With<Self, P2> where
Self: Sized,
P2: Parser<Input>,
Discards the value of the self
parser and returns the value of p
.
Fails if any of the parsers fails. Read more
sourcefn skip<P2>(self, p: P2) -> Skip<Self, P2> where
Self: Sized,
P2: Parser<Input>,
fn skip<P2>(self, p: P2) -> Skip<Self, P2> where
Self: Sized,
P2: Parser<Input>,
Discards the value of the p
parser and returns the value of self
.
Fails if any of the parsers fails. Read more
sourcefn and<P2>(self, p: P2) -> (Self, P2) where
Self: Sized,
P2: Parser<Input>,
fn and<P2>(self, p: P2) -> (Self, P2) where
Self: Sized,
P2: Parser<Input>,
Parses with self
followed by p
.
Succeeds if both parsers succeed, otherwise fails.
Returns a tuple with both values on success. Read more
sourcefn or<P2>(self, p: P2) -> Or<Self, P2> where
Self: Sized,
P2: Parser<Input, Output = Self::Output>,
fn or<P2>(self, p: P2) -> Or<Self, P2> where
Self: Sized,
P2: Parser<Input, Output = Self::Output>,
Returns a parser which attempts to parse using self
. If self
fails without committing
it tries to consume the same input using p
. Read more
sourcefn then<N, F>(self, f: F) -> Then<Self, F> where
Self: Sized,
F: FnMut(Self::Output) -> N,
N: Parser<Input>,
fn then<N, F>(self, f: F) -> Then<Self, F> where
Self: Sized,
F: FnMut(Self::Output) -> N,
N: Parser<Input>,
Parses using self
and then passes the value to f
which returns a parser used to parse
the rest of the input. Read more
sourcefn then_partial<N, F>(self, f: F) -> ThenPartial<Self, F> where
Self: Sized,
F: FnMut(&mut Self::Output) -> N,
N: Parser<Input>,
fn then_partial<N, F>(self, f: F) -> ThenPartial<Self, F> where
Self: Sized,
F: FnMut(&mut Self::Output) -> N,
N: Parser<Input>,
sourcefn then_ref<N, F>(self, f: F) -> ThenRef<Self, F> where
Self: Sized,
F: FnMut(&Self::Output) -> N,
N: Parser<Input>,
fn then_ref<N, F>(self, f: F) -> ThenRef<Self, F> where
Self: Sized,
F: FnMut(&Self::Output) -> N,
N: Parser<Input>,
Parses using self
and then passes a reference to the value to f
which returns a parser
used to parse the rest of the input. The value is then combined with the output of f
. Read more
sourcefn map<F, B>(self, f: F) -> Map<Self, F> where
Self: Sized,
F: FnMut(Self::Output) -> B,
fn map<F, B>(self, f: F) -> Map<Self, F> where
Self: Sized,
F: FnMut(Self::Output) -> B,
Uses f
to map over the parsed value. Read more
fn map_input<F, B>(self, f: F) -> MapInput<Self, F> where
Self: Sized,
F: FnMut(Self::Output, &mut Input) -> B,
sourcefn flat_map<F, B>(self, f: F) -> FlatMap<Self, F> where
Self: Sized,
F: FnMut(Self::Output) -> Result<B, <Input as StreamOnce>::Error>,
fn flat_map<F, B>(self, f: F) -> FlatMap<Self, F> where
Self: Sized,
F: FnMut(Self::Output) -> Result<B, <Input as StreamOnce>::Error>,
Uses f
to map over the output of self
. If f
returns an error the parser fails. Read more
sourcefn message<S>(self, msg: S) -> Message<Self, S> where
Self: Sized,
S: for<'s> ErrorInfo<'s, Input::Token, Input::Range>,
fn message<S>(self, msg: S) -> Message<Self, S> where
Self: Sized,
S: for<'s> ErrorInfo<'s, Input::Token, Input::Range>,
Parses with self
and if it fails, adds the message msg
to the error. Read more
sourcefn expected<S>(self, msg: S) -> Expected<Self, S> where
Self: Sized,
S: for<'s> ErrorInfo<'s, Input::Token, Input::Range>,
fn expected<S>(self, msg: S) -> Expected<Self, S> where
Self: Sized,
S: for<'s> ErrorInfo<'s, Input::Token, Input::Range>,
Parses with self
and if it fails without consuming any input any expected errors are
replaced by msg
. msg
is then used in error messages as “Expected msg
”. Read more
sourcefn silent(self) -> Silent<Self> where
Self: Sized,
fn silent(self) -> Silent<Self> where
Self: Sized,
Parses with self
, if it fails without consuming any input any expected errors that would
otherwise be emitted by self
are suppressed. Read more
sourcefn and_then<F, O, E>(self, f: F) -> AndThen<Self, F> where
Self: Parser<Input> + Sized,
F: FnMut(Self::Output) -> Result<O, E>,
E: Into<<Input::Error as ParseError<Input::Token, Input::Range, Input::Position>>::StreamError>,
fn and_then<F, O, E>(self, f: F) -> AndThen<Self, F> where
Self: Parser<Input> + Sized,
F: FnMut(Self::Output) -> Result<O, E>,
E: Into<<Input::Error as ParseError<Input::Token, Input::Range, Input::Position>>::StreamError>,
Parses with self
and applies f
on the result if self
parses successfully.
f
may optionally fail with an error which is automatically converted to a ParseError
. Read more
sourcefn iter(
self,
input: &mut Input
) -> Iter<'_, Input, Self, Self::PartialState, FirstMode>ⓘNotable traits for Iter<'a, Input, P, S, M>impl<'a, Input, P, S, M> Iterator for Iter<'a, Input, P, S, M> where
Input: Stream,
P: Parser<Input>,
S: BorrowMut<P::PartialState>,
M: ParseMode, type Item = P::Output;
where
Self: Parser<Input> + Sized,
fn iter(
self,
input: &mut Input
) -> Iter<'_, Input, Self, Self::PartialState, FirstMode>ⓘNotable traits for Iter<'a, Input, P, S, M>impl<'a, Input, P, S, M> Iterator for Iter<'a, Input, P, S, M> where
Input: Stream,
P: Parser<Input>,
S: BorrowMut<P::PartialState>,
M: ParseMode, type Item = P::Output;
where
Self: Parser<Input> + Sized,
Input: Stream,
P: Parser<Input>,
S: BorrowMut<P::PartialState>,
M: ParseMode, type Item = P::Output;
sourcefn partial_iter<'a, 's, M>(
self,
mode: M,
input: &'a mut Input,
partial_state: &'s mut Self::PartialState
) -> Iter<'a, Input, Self, &'s mut Self::PartialState, M>ⓘNotable traits for Iter<'a, Input, P, S, M>impl<'a, Input, P, S, M> Iterator for Iter<'a, Input, P, S, M> where
Input: Stream,
P: Parser<Input>,
S: BorrowMut<P::PartialState>,
M: ParseMode, type Item = P::Output;
where
Self: Parser<Input> + Sized,
M: ParseMode,
fn partial_iter<'a, 's, M>(
self,
mode: M,
input: &'a mut Input,
partial_state: &'s mut Self::PartialState
) -> Iter<'a, Input, Self, &'s mut Self::PartialState, M>ⓘNotable traits for Iter<'a, Input, P, S, M>impl<'a, Input, P, S, M> Iterator for Iter<'a, Input, P, S, M> where
Input: Stream,
P: Parser<Input>,
S: BorrowMut<P::PartialState>,
M: ParseMode, type Item = P::Output;
where
Self: Parser<Input> + Sized,
M: ParseMode,
Input: Stream,
P: Parser<Input>,
S: BorrowMut<P::PartialState>,
M: ParseMode, type Item = P::Output;
sourcefn boxed<'a>(
self
) -> Box<dyn Parser<Input, Output = Self::Output, PartialState = Self::PartialState> + 'a>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
where
Self: Sized + 'a,
fn boxed<'a>(
self
) -> Box<dyn Parser<Input, Output = Self::Output, PartialState = Self::PartialState> + 'a>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
where
Self: Sized + 'a,
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Turns the parser into a trait object by putting it in a Box
. Can be used to easily
return parsers from functions without naming the type. Read more
sourcefn left<R>(self) -> Either<Self, R> where
Self: Sized,
R: Parser<Input, Output = Self::Output>,
fn left<R>(self) -> Either<Self, R> where
Self: Sized,
R: Parser<Input, Output = Self::Output>,
Auto Trait Implementations
impl<F, I, P> RefUnwindSafe for Iterate<F, I, P> where
I: RefUnwindSafe,
P: RefUnwindSafe,
impl<F, I, P> Send for Iterate<F, I, P> where
I: Send,
P: Send,
impl<F, I, P> Sync for Iterate<F, I, P> where
I: Sync,
P: Sync,
impl<F, I, P> Unpin for Iterate<F, I, P> where
I: Unpin,
P: Unpin,
impl<F, I, P> UnwindSafe for Iterate<F, I, P> where
I: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more