pub fn take_till<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_till
with input wrapped in nom8::input::Streaming
Expand description
Returns the longest input slice (if any) 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).
Streaming Specific
Streaming version will return a Err::Incomplete(Needed::new(1))
if the match reaches the
end of input or if there was not match.
Example
use nom8::bytes::streaming::take_till;
fn till_colon(s: &str) -> IResult<&str, &str> {
take_till(|c| c == ':')(s)
}
assert_eq!(till_colon("latin:123"), Ok((":123", "latin")));
assert_eq!(till_colon(":empty matched"), Ok((":empty matched", ""))); //allowed
assert_eq!(till_colon("12345"), Err(Err::Incomplete(Needed::new(1))));
assert_eq!(till_colon(""), Err(Err::Incomplete(Needed::new(1))));
WARNING: Deprecated, replaced with nom8::bytes::take_till
with input wrapped in nom8::input::Streaming