pub fn take_until_bytes<'a, Input>(
    needle: &'a [u8]
) -> take_until_bytes<'a, Input> where
    <Input as StreamOnce>::Error: ParseError<<Input as StreamOnce>::Token, <Input as StreamOnce>::Range, <Input as StreamOnce>::Position>,
    Input: Stream,
    Input: RangeStream,
    Input::Range: AsRef<[u8]> + Range
Expand description

Zero-copy parser which reads a range of 0 or more tokens until needle is found.

If a, ‘b’ or c is not found, the parser will return an error.

Optimized variant of take_until_range

use combine::*;
use combine::parser::byte::take_until_bytes;
assert_eq!(
    take_until_bytes(&b"\r\n"[..]).easy_parse(&b"abc\r\n"[..]).map(|(x, _)| x),
    Ok((&b"abc"[..]))
);
// Also works on strings as long as `needle` is UTF-8
assert_eq!(
    take_until_bytes("\r\n".as_bytes()).easy_parse("abc\r\n").map(|(x, _)| x),
    Ok(("abc"))
);