Macro nom::fold_many0[][src]

macro_rules! fold_many0 {
    ($i:expr, $submac:ident!( $($args:tt)* ), $init:expr, $f:expr) => { ... };
    ($i:expr, $f:expr, $init:expr, $fold_f:expr) => { ... };
}

fold_many0!(I -> IResult<I,O>, R, Fn(R, O) -> R) => I -> IResult<I, R> Applies the parser 0 or more times and folds the list of return values

the embedded parser may return Incomplete

 named!(multi<&[u8], Vec<&[u8]> >,
   fold_many0!( tag!( "abcd" ), Vec::new(), |mut acc: Vec<_>, item| {
     acc.push(item);
     acc
 }));

 let a = b"abcdabcdefgh";
 let b = b"azerty";

 let res = vec![&b"abcd"[..], &b"abcd"[..]];
 assert_eq!(multi(&a[..]),Ok((&b"efgh"[..], res)));
 assert_eq!(multi(&b[..]),Ok((&b"azerty"[..], Vec::new())));

0 or more