[][src]Macro nom::many_m_n

macro_rules! many_m_n {
    ($i:expr, $m:expr, $n: expr, $submac:ident!( $($args:tt)* )) => { ... };
    ($i:expr, $m:expr, $n: expr, $f:expr) => { ... };
}

many_m_n!(usize, usize, I -> IResult<I,O>) => I -> IResult<I, Vec<O>> Applies the parser between m and n times (n included) and returns the list of results in a Vec

the embedded parser may return Incomplete

 named!(multi<&[u8], Vec<&[u8]> >, many_m_n!(2, 4, tag!( "abcd" ) ) );

 let a = b"abcdefgh";
 let b = b"abcdabcdefgh";
 let c = b"abcdabcdabcdabcdabcdefgh";

 assert_eq!(multi(&a[..]), Err(Err::Error(error_position!(&a[..], ErrorKind::ManyMN))));
 let res = vec![&b"abcd"[..], &b"abcd"[..]];
 assert_eq!(multi(&b[..]),Ok((&b"efgh"[..], res)));
 let res2 = vec![&b"abcd"[..], &b"abcd"[..], &b"abcd"[..], &b"abcd"[..]];
 assert_eq!(multi(&c[..]),Ok((&b"abcdefgh"[..], res2)));