Macro nom::length_data [−][src]
length_data!(I -> IResult<I, nb>) => O
length_data
gets a number from the first parser, then takes a subslice of the input
of that size and returns that subslice
use nom::number::complete::be_u8; named!(parser, length_data!(be_u8)); assert_eq!(parser(&b"\x06abcabcabc"[..]), Ok((&b"abc"[..], &b"abcabc"[..]))); assert_eq!(parser(&b"\x06abc"[..]), Err(Err::Incomplete(Needed::Size(6))));