Function take
fn take<C, I, Error: ParseError<I>>(count: C) -> impl Parser<I, Output = I, Error = Error>
where
I: Input,
C: ToUsize
Returns an input slice containing the first N input elements (Input[..N]).
Streaming Specific
Streaming version if the input has less than N elements, take will
return a Err::Incomplete(Needed::new(M)) where M is the number of
additional bytes the parser would need to succeed.
It is well defined for &[u8] as the number of elements is the byte size,
but for types like &str, we cannot know how many bytes correspond for
the next few chars, so the result will be Err::Incomplete(Needed::Unknown)
Example
# use ;
use take;
assert_eq!;
assert_eq!;
assert_eq!;