Macro nom::take_till [−][src]
take_till!(T -> bool) => &[T] -> IResult<&[T], &[T]>
returns the longest list of bytes until the provided function succeeds
The argument is either a function &[T] -> bool
or a macro returning a bool
.
Example
named!( till_colon, take_till!(|ch| ch == b':') ); let r = till_colon(&b"abcd:efgh"[..]); assert_eq!(r, Ok((&b":efgh"[..], &b"abcd"[..]))); let r2 = till_colon(&b":abcdefgh"[..]); // empty match is allowed assert_eq!(r2, Ok((&b":abcdefgh"[..], &b""[..])));