[−][src]Function combine::parser::byte::take_until_bytes
pub fn take_until_bytes<'a, I>(needle: &'a [u8]) -> take_until_bytes<'a, I> where
<I as StreamOnce>::Error: ParseError<<I as StreamOnce>::Item, <I as StreamOnce>::Range, <I as StreamOnce>::Position>,
I: RangeStream + FullRangeStream,
I::Range: AsRef<[u8]> + Range,
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")) );