Macro nom::count [−][src]
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"efgh"[..], ErrorKind::Tag))));