Function winnow::bytes::streaming::take_till1
source · pub fn take_till1<T, I, Error: ParseError<I>>(
list: T
) -> impl Fn(I) -> IResult<I, <I as Stream>::Slice, Error>where
I: Stream,
T: ContainsToken<<I as Stream>::Token>,👎Deprecated since 0.1.0: Replaced with <code>winnow::bytes::take_till1</code> with input wrapped in <code>winnow::Partial</code>
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).
Partial Specific
Partial version will return a ErrMode::Incomplete(Needed::new(1)) if the match reaches the
end of input or if there was not match.
Example
use winnow::bytes::streaming::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(ErrMode::Backtrack(Error::new(":empty matched", ErrorKind::TakeTill1))));
assert_eq!(till_colon("12345"), Err(ErrMode::Incomplete(Needed::new(1))));
assert_eq!(till_colon(""), Err(ErrMode::Incomplete(Needed::new(1))));WARNING: Deprecated, replaced with winnow::bytes::take_till1 with input wrapped in winnow::Partial