Function chomp::combinators::many1
[−]
[src]
pub fn many1<I: Input, T, E, F, U>(i: I, f: F) -> ParseResult<I, T, E> where
F: FnMut(I) -> ParseResult<I, U, E>,
T: FromIterator<U>,
Parses at least one instance of f
and continues until it does no longer match, collecting
all matches into the type T: FromIterator
.
Note: If the last parser succeeds on the last input item then this parser is still considered incomplete as there might be more data to fill.
Note: Allocates data.
use chomp::prelude::{Error, parse_only, token, many1, take_while1}; let p = |i| many1(i, |i| take_while1(i, |c| c != b',' && c != b' ') .bind(|i, c| token(i, b',') .map(|_| c))); assert_eq!(parse_only(&p, b"a "), Err((&b" "[..], Error::expected(b',')))); assert_eq!(parse_only(&p, b"a, "), Ok(vec![&b"a"[..]]));