Function chomp::combinators::many [] [src]

pub fn many<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 many instances of f until it does no longer match, collecting all matches into the type T: FromIterator.

Note: Allocates data.

use chomp::prelude::{parse_only, token, many, take_while1};

let r: Result<Vec<_>, _> = parse_only(|i| many(i,
    |i| take_while1(i, |c| c != b',' && c != b' ')
        .bind(|i, c| token(i, b',')
                     .map(|_| c))),
    b"a,bc,cd ");

assert_eq!(r, Ok(vec![&b"a"[..], &b"bc"[..]]));