[−][src]Function gchemol_parser::parsers::streaming::take
pub fn take<C, Input, Error>(count: C) -> impl Fn(Input) where
C: ToUsize,
Error: ParseError<Input>,
Input: InputIter + InputTake,
Returns an input slice containing the first N input elements (Input[..N])
Streaming Specific
Streaming version will return a Err::Incomplete(Needed::Size(N))
where N is the
argument if the input is less than the length provided
Example
use nom::bytes::streaming::take; fn take6(s: &str) -> IResult<&str, &str> { take(6usize)(s) } assert_eq!(take6("1234567"), Ok(("7", "123456"))); assert_eq!(take6("things"), Ok(("", "things"))); assert_eq!(take6("short"), Err(Err::Incomplete(Needed::Size(6)))); //N doesn't change assert_eq!(take6(""), Err(Err::Incomplete(Needed::Size(6))));