nom::count!
[−]
[src]
macro_rules! count { ($i:expr, $submac:ident!( $($args:tt)* ), $typ:ty, $count: expr) => { ... }; ($i:expr, $f:expr, $typ:ty, $count: expr) => { ... }; }
Applies the child parser a specified number of times
named!(counter< [&[u8]; 2] >, count!( tag!( "abcd" ), &[u8], 2 ) ); let a = b"abcdabcdabcdef"; let b = b"abcdefgh"; let res = [&b"abcd"[..], &b"abcd"[..]]; assert_eq!(counter(&a[..]), Done(&b"abcdef"[..], res)); assert_eq!(counter(&b[..]), Error(Position(ErrorCode::Count as u32, &b[..])));