Macro nom::many_m_n
[−]
[src]
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[..]),Error(error_position!(ErrorKind::ManyMN,&a[..]))); let res = vec![&b"abcd"[..], &b"abcd"[..]]; assert_eq!(multi(&b[..]), Done(&b"efgh"[..], res)); let res2 = vec![&b"abcd"[..], &b"abcd"[..], &b"abcd"[..], &b"abcd"[..]]; assert_eq!(multi(&c[..]), Done(&b"abcdefgh"[..], res2));