Function many
fn many<I, E, Collection, F, G>(range: G, parser: F) -> impl Parser<I, Output = Collection, Error = E>
where
I: Clone + Input,
F: Parser<I, Error = E>,
Collection: Extend<<F as Parser<I>>::Output> + Default,
E: ParseError<I>,
G: NomRange<usize>
Repeats the embedded parser and collects the results in a type implementing Extend + Default.
Fails if the amount of time the embedded parser is run is not
within the specified range.
Arguments
rangeConstrains the number of iterations.- A range without an upper bound
a..is equivalent to a range ofa..=usize::MAX. - A single
usizevalue is equivalent tovalue..=value. - An empty range is invalid.
- A range without an upper bound
parseThe parser to apply.
# extern crate nom;
# use ;
use many;
use tag;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
This is not limited to Vec, other collections like HashMap
can be used:
# extern crate nom;
# use ;
use many;
use ;
use ;
use AsChar;
use HashMap;
assert_eq!;
If more control is needed on the default value, [fold] can be used instead:
# extern crate nom;
# use ;
use fold;
use tag;
assert_eq!;