Macro nom::fold_many1
[−]
[src]
macro_rules! fold_many1 { ($i:expr, $submac:ident!( $($args:tt)* ), $init:expr, $f:expr) => { ... }; ($i:expr, $f:expr, $init:expr, $fold_f:expr) => { ... }; }
fold_many1!(I -> IResult<I,O>, R, Fn(R, O) -> R) => I -> IResult<I, R>
Applies the parser 1 or more times and folds the list of return values
the embedded parser may return Incomplete
named!(multi<&[u8], Vec<&[u8]> >, fold_many1!( 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[..]), Done(&b"efgh"[..], res)); assert_eq!(multi(&b[..]), Error(error_position!(ErrorKind::Many1,&b[..])));