Macro nom::count [−][src]
macro_rules! count { ($i:expr, $submac:ident!( $($args:tt)* ), $count: expr) => { ... }; ($i:expr, $f:expr, $count: expr) => { ... }; }
count!(I -> IResult<I,O>, nb) => I -> IResult<I, Vec<O>>
Applies the child parser a specified number of times
named!(counter< Vec<&[u8]> >, count!( tag!( "abcd" ), 2 ) ); let a = b"abcdabcdabcdef"; let b = b"abcdefgh"; let res = vec![&b"abcd"[..], &b"abcd"[..]]; assert_eq!(counter(&a[..]),Ok((&b"abcdef"[..], res))); assert_eq!(counter(&b[..]), Err(Err::Error(error_position!(&b[..], ErrorKind::Count))));