Macro nom::length_count [−][src]
length_count!(I -> IResult<I, nb>, I -> IResult<I,O>) => I -> IResult<I, Vec<O>>
gets a number from the first parser, then applies the second parser that many times
use nom::number::complete::be_u8; named!(parser<Vec<&[u8]>>, length_count!(be_u8, tag!("abc"))); assert_eq!(parser(&b"\x02abcabcabc"[..]), Ok(((&b"abc"[..], vec![&b"abc"[..], &b"abc"[..]])))); assert_eq!(parser(&b"\x04abcabcabc"[..]), Err(Err::Incomplete(Needed::Size(3))));