Macro peel_ip::prelude::count
[−]
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[..]), Done(&b"abcdef"[..], res)); assert_eq!(counter(&b[..]), Error(error_position!(ErrorKind::Count, &b[..])));