Function nom::bytes::complete::take_until [−][src]
pub fn take_until<T, Input, Error: ParseError<Input>>(
tag: T
) -> impl Fn(Input) -> IResult<Input, Input, Error> where
Input: InputTake + FindSubstring<T>,
T: InputLength + Clone,
Returns the longest input slice till it matches the pattern.
It doesn’t consume the pattern. It will return Err(Err::Error((_, ErrorKind::TakeUntil)))
if the pattern wasn’t met
Example
use nom::bytes::complete::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::Error(("hello, world", ErrorKind::TakeUntil)))); assert_eq!(until_eof(""), Err(Err::Error(("", ErrorKind::TakeUntil))));