[][src]Function gchemol_parser::parsers::streaming::take_until

pub fn take_until<T, Input, Error>(tag: T) -> impl Fn(Input) where
    Error: ParseError<Input>,
    Input: InputTake + FindSubstring<T>,
    T: InputLength + Clone

Returns the longest input slice till it matches the pattern.

It doesn't consume the pattern

Streaming Specific

Streaming version will return a Err::Incomplete(Needed::Size(N)) if the input doesn't contain the pattern or if the input is smaller than the pattern

Example

use nom::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(Err::Incomplete(Needed::Size(3))));
assert_eq!(until_eof(""), Err(Err::Incomplete(Needed::Size(3))));