Function winnow::bytes::complete::take_until1
source · pub fn take_until1<T, I, Error: ParseError<I>>(
tag: T
) -> impl Fn(I) -> IResult<I, <I as Stream>::Slice, Error>where
I: Stream + FindSlice<T>,
T: SliceLen + Clone,👎Deprecated since 0.1.0: Replaced with <code>winnow::bytes::take_until1</code>
Expand description
Returns the non empty input slice up to the first occurrence of the pattern.
It doesn’t consume the pattern. It will return Err(ErrMode::Backtrack((_, ErrorKind::TakeUntil)))
if the pattern wasn’t met.
Example
use winnow::bytes::complete::take_until1;
fn until_eof(s: &str) -> IResult<&str, &str> {
take_until1("eof")(s)
}
assert_eq!(until_eof("hello, worldeof"), Ok(("eof", "hello, world")));
assert_eq!(until_eof("hello, world"), Err(ErrMode::Backtrack(Error::new("hello, world", ErrorKind::TakeUntil))));
assert_eq!(until_eof(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::TakeUntil))));
assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
assert_eq!(until_eof("eof"), Err(ErrMode::Backtrack(Error::new("eof", ErrorKind::TakeUntil))));WARNING: Deprecated, replaced with winnow::bytes::take_until1