Function nom8::bytes::complete::take_till1
source · pub fn take_till1<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_till1
Expand description
Returns the longest (at least 1) input slice till a predicate is met.
The parser will return the longest slice till the given predicate (a function that takes the input and returns a bool).
It will return Err(Err::Error((_, ErrorKind::TakeTill1)))
if the input is empty or the
predicate matches the first input.
Example
use nom8::bytes::complete::take_till1;
fn till_colon(s: &str) -> IResult<&str, &str> {
take_till1(|c| c == ':')(s)
}
assert_eq!(till_colon("latin:123"), Ok((":123", "latin")));
assert_eq!(till_colon(":empty matched"), Err(Err::Error(Error::new(":empty matched", ErrorKind::TakeTill1))));
assert_eq!(till_colon("12345"), Ok(("", "12345")));
assert_eq!(till_colon(""), Err(Err::Error(Error::new("", ErrorKind::TakeTill1))));
WARNING: Deprecated, replaced with nom8::bytes::take_till1