Skip to main content

IterableParserExt

Trait IterableParserExt 

Source
pub trait IterableParserExt<I: Positioned + ?Sized>: IterableParser<I> {
Show 37 methods // Provided methods fn parse_iterable<'a, 'b>( &'a mut self, input: &'b mut I, ) -> IterableParserStream<'a, 'b, Self, I, Self::State> where I: Unpin { ... } fn boxed<'a>( self, ) -> Box<dyn IterableParser<I, Item = Self::Item, 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: IterableParser<I, Item = Self::Item> { ... } fn right<L>(self) -> Either<L, Self> where Self: Sized, L: IterableParser<I, Item = Self::Item> { ... } fn complete(self) -> Skip<Self, Eof<I>> where Self: Sized { ... } fn chain<P>(self, p: P) -> (Self, P) where Self: Sized, P: IterableParser<I, Item = Self::Item> { ... } fn or<P>(self, p: P) -> Or<Self, P> where I: Input, Self: Sized, P: IterableParser<I, Item = Self::Item> { ... } fn opt(self) -> Opt<Self> where Self: Sized, I: Input { ... } fn skip<P>(self, p: P) -> Skip<Self, P> where Self: Sized, P: Parser<I> { ... } fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R> where Self: Sized, L: Parser<I>, R: Parser<I> { ... } fn discard(self) -> Discard<Self> where Self: Sized { ... } fn count(self) -> Count<Self> where Self: Sized { ... } fn collect<E: Default + Extend<Self::Item>>(self) -> Collect<Self, E> where Self: Sized { ... } fn first(self) -> Nth<Self> where Self: Sized { ... } fn last(self) -> Last<Self> where Self: Sized { ... } fn nth(self, n: usize) -> Nth<Self> where Self: Sized { ... } fn fill<const N: usize>(self, start: usize) -> Indices<Self, N> where Self: Sized { ... } fn indices<const N: usize>(self, ns: [usize; N]) -> Indices<Self, N> where Self: Sized { ... } fn flat_repeat<R>(self, range: R) -> FlatRepeat<Self, R> where Self: Sized, I: Input, R: RangeBounds<usize> { ... } fn flat_times(self, n: usize) -> FlatTimes<Self> where Self: Sized { ... } 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> { ... } 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> { ... } fn flat_sep_by_times<P>( self, sep: P, count: usize, ) -> FlatSepByTimes<Self, P> where Self: Sized, P: Parser<I> { ... } fn flat_sep_by_end_times<P>( self, sep: P, count: usize, ) -> FlatSepByEndTimes<Self, P> where Self: Sized, I: Input, P: Parser<I> { ... } fn flat_until<P>(self, end: P) -> FlatUntil<Self, P> where Self: Sized, I: Input, P: Parser<I> { ... } fn map<F, O>(self, f: F) -> Map<Self, F> where Self: Sized, F: FnMut(Self::Item) -> O { ... } 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> { ... } fn enumerate(self) -> Enumerate<Self> where Self: Sized { ... } fn flatten(self) -> Flatten<Self> where Self: Sized, Self::Item: IntoIterator { ... } fn filter<F>(self, f: F) -> Filter<Self, F> where Self: Sized, F: FnMut(&Self::Item) -> bool { ... } 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 { ... } 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> { ... } fn reduce<F>(self, f: F) -> Reduce<Self, F> where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item { ... } 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> { ... } 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> { ... } 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> { ... }
}

Provided Methods§

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.

This method is a conventional method, and equivalent to self.skip(eof()).

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.

This method is equivalent to self.nth(0), and if the stream is empty, it returns None.

Source

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

Consumes all outputs, returns the last element.

If the stream is empty, it returns None.

Source

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

Consumes all outputs, returns the nth element.

Note that n starts from 0 and if the length of stream less than n, it returns None.

Source

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

Consumes all outputs, returns N elements from index start.

This method is equivalent to self.indexes([start, start+1, ... , start+N-1]).

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.

Note that n starts from 0 and if the length of stream less than n, it returns None.

§Panics

if ns is not ascending ordered.

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.

The returned parser’s item will be (usize, Self::Item).

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).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§