Function winnow::bytes::streaming::take_until

source ·
pub fn take_until<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_until0</code> with input wrapped in <code>winnow::Partial</code>
Expand description

Returns the input slice up to the first occurrence of the pattern.

It doesn’t consume the pattern.

Partial Specific

Partial version will return a ErrMode::Incomplete(Needed::new(N)) if the input doesn’t contain the pattern or if the input is smaller than the pattern.

Example

use winnow::bytes::streaming::take_until;

fn until_eof(s: &str) -> IResult<&str, &str> {
  take_until("eof")(s)
}

assert_eq!(until_eof("hello, worldeof"), Ok(("eof", "hello, world")));
assert_eq!(until_eof("hello, world"), Err(ErrMode::Incomplete(Needed::Unknown)));
assert_eq!(until_eof("hello, worldeo"), Err(ErrMode::Incomplete(Needed::Unknown)));
assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));

WARNING: Deprecated, replaced with winnow::bytes::take_until0 with input wrapped in winnow::Partial