nom::count_fixed! [] [src]

macro_rules! count_fixed {
    ($i:expr, $typ:ty, $submac:ident!( $($args:tt)* ), $count: expr) => { ... };
    ($i:expr, $typ: ty, $f:ident, $count: expr) => { ... };
    ($i:expr, $submac:ident!( $($args:tt)* ), $count: expr) => { ... };
    ($i:expr, $f:ident, $count: expr) => { ... };
}

Applies the child parser a fixed number of times and returns a fixed size array

 named!(counter< [&[u8]; 2] >, count_fixed!( &[u8], tag!( "abcd" ), 2 ) );
 // can omit the type specifier if returning slices
 // named!(counter< [&[u8]; 2] >, count_fixed!( tag!( "abcd" ), 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[..])));