Function combine::many

source ·
pub fn many<F, Input, P>(p: P) -> Many<F, P>
where Input: Stream, P: Parser<Input>, F: Extend<P::Output> + Default,
Expand description

Parses p zero or more times returning a collection with the values from p.

If the returned collection cannot be inferred type annotations must be supplied, either by annotating the resulting type binding let collection: Vec<_> = ... or by specializing when calling many, many::<Vec<_>, _, _>(...).

NOTE: If p can succeed without consuming any input this may hang forever as many will repeatedly use p to parse the same location in the input every time

let result = many(digit())
    .parse("123A")
    .map(|x| x.0);
assert_eq!(result, Ok(vec!['1', '2', '3']));