pub trait ParserExt<I: Positioned + ?Sized>: Parser<I> {
Show 34 methods
// Provided methods
fn parse<'a, 'b>(
&'a mut self,
input: &'b mut I,
) -> ParseFuture<'a, 'b, Self, I, Self::State>
where I: Unpin { ... }
fn boxed<'a>(
self,
) -> Box<dyn Parser<I, Output = Self::Output, State = Self::State> + 'a>
where Self: Sized + 'a { ... }
fn no_state(self) -> NoState<Self, Self::State>
where Self: Sized { ... }
fn left<R>(self) -> Either<Self, R> ⓘ
where Self: Sized,
R: Parser<I, Output = Self::Output> { ... }
fn right<L>(self) -> Either<L, Self> ⓘ
where Self: Sized,
L: Parser<I, Output = Self::Output> { ... }
fn complete(self) -> Skip<Self, Eof<I>> ⓘ
where Self: Sized { ... }
fn with_position(self) -> WithPosition<Self> ⓘ
where Self: Sized { ... }
fn peek(self) -> Peek<Self> ⓘ
where Self: Sized,
I: Input { ... }
fn fail(self) -> Fail<Self> ⓘ
where Self: Sized,
I: Input { ... }
fn and<P>(self, p: P) -> (Self, P) ⓘ
where Self: Sized,
P: Parser<I> { ... }
fn skip<P>(self, p: P) -> Skip<Self, P> ⓘ
where Self: Sized,
P: Parser<I> { ... }
fn prefix<P>(self, p: P) -> Prefix<Self, P> ⓘ
where Self: Sized { ... }
fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R> ⓘ
where Self: Sized,
L: Parser<I>,
R: Parser<I> { ... }
fn or<P>(self, other: P) -> Or<Self, P> ⓘ
where Self: Sized,
I: Input,
P: Parser<I, Output = Self::Output> { ... }
fn opt(self) -> Opt<Self> ⓘ
where Self: Sized,
I: Input { ... }
fn once(self) -> Times<Self> ⓘ
where Self: Sized,
I: Positioned { ... }
fn times(self, n: usize) -> Times<Self> ⓘ
where Self: Sized,
I: Positioned { ... }
fn sep_by_times<P, R>(self, sep: P, count: usize) -> SepByTimes<Self, P> ⓘ
where Self: Sized,
P: Parser<I> { ... }
fn sep_by_end_times<P, R>(
self,
sep: P,
count: usize,
) -> SepByEndTimes<Self, P> ⓘ
where Self: Sized,
I: Input,
P: Parser<I> { ... }
fn repeat<R>(self, range: R) -> Repeat<Self, R> ⓘ
where Self: Sized,
R: RangeBounds<usize>,
I: Input { ... }
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 { ... }
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 { ... }
fn then<F, Q>(self, f: F) -> Then<Self, F> ⓘ
where Self: Sized,
F: FnMut(Self::Output) -> Q { ... }
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> { ... }
fn until<P>(self, end: P) -> Until<Self, P> ⓘ
where Self: Sized,
P: Parser<I>,
I: Input { ... }
fn discard(self) -> Discard<Self> ⓘ
where Self: Sized { ... }
fn map<F, O>(self, f: F) -> Map<Self, F> ⓘ
where Self: Sized,
F: FnMut(Self::Output) -> O { ... }
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> { ... }
fn satisfy<F, O>(self, f: F) -> Satisfy<Self, F> ⓘ
where Self: Sized,
F: FnMut(&Self::Output) -> bool { ... }
fn map_err<F, E>(self, f: F) -> MapErr<Self, F> ⓘ
where Self: Sized,
F: FnMut(Expects) -> Expects,
E: Into<Expects> { ... }
fn expect<E: Into<Expects>>(self, expected: E) -> Expect<Self> ⓘ
where Self: Sized,
I::Ok: Clone { ... }
fn spanned(self) -> Spanned<Self> ⓘ
where Self: Sized { ... }
fn exclusive<E: Into<Expects>>(self, expected: E) -> Exclusive<Self> ⓘ
where Self: Sized,
I::Ok: Clone { ... }
fn rewindable(self) -> Rewindable<Self> ⓘ
where Self: Sized { ... }
}Expand description
An extension trait for Parser.
Provided Methods§
Sourcefn 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.
Sourcefn boxed<'a>(
self,
) -> Box<dyn Parser<I, Output = Self::Output, State = Self::State> + 'a>where
Self: Sized + 'a,
Available on crate feature alloc only.
fn boxed<'a>(
self,
) -> Box<dyn Parser<I, Output = Self::Output, State = Self::State> + 'a>where
Self: Sized + 'a,
alloc only.Wraps the parser into a Box.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn complete(self) -> Skip<Self, Eof<I>> ⓘwhere
Self: Sized,
fn complete(self) -> Skip<Self, Eof<I>> ⓘwhere
Self: Sized,
Parses the input completedly.
This method is a conventional method, and equivalent to self.skip(eof()).
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
This method is equivalent to self.times(1).
Sourcefn 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.
Sourcefn 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.
Sourcefn 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).
Sourcefn 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.
Sourcefn 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.
Sourcefn 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).
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn exclusive<E: Into<Expects>>(self, expected: E) -> Exclusive<Self> ⓘ
fn exclusive<E: Into<Expects>>(self, expected: E) -> Exclusive<Self> ⓘ
Overrides parsing errors as “exclusive”.
Sourcefn rewindable(self) -> Rewindable<Self> ⓘwhere
Self: Sized,
fn rewindable(self) -> Rewindable<Self> ⓘwhere
Self: Sized,
Modifies “exclusive” errors as rewindable.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".