Function nom8::bytes::complete::take_while1
source · pub fn take_while1<T, Input, Error: ParseError<Input>>(
list: T
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>where
Input: InputTakeAtPosition + IntoOutput,
T: FindToken<<Input as InputTakeAtPosition>::Item>,
👎Deprecated since 8.0.0: Replaced with
nom8::bytes::take_while1
Expand description
Returns the longest (at least 1) input slice that matches the predicate.
The parser will return the longest slice that matches the given predicate (a function that takes the input and returns a bool).
It will return an Err(Err::Error((_, ErrorKind::TakeWhile1)))
if the pattern wasn’t met.
Example
use nom8::bytes::complete::take_while1;
use nom8::input::AsChar;
fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
take_while1(AsChar::is_alpha)(s)
}
assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
assert_eq!(alpha(b"latin"), Ok((&b""[..], &b"latin"[..])));
assert_eq!(alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhile1))));
WARNING: Deprecated, replaced with nom8::bytes::take_while1