Function chomp::combinators::many1 [] [src]

pub fn many1<'a, I, T, E, F, U>(i: Input<'a, I>, f: F) -> ParseResult<'a, I, T, E> where I: Copy, U: 'a, F: FnMut(Input<'a, I>) -> ParseResult<'a, 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::{ParseError, 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(ParseError::Error(b" ", Error::Expected(b','))));
 assert_eq!(parse_only(&p, b"a, "), Ok(vec![&b"a"[..]]));