Macro nom::take_till[][src]

macro_rules! take_till {
    ($input:expr, $submac:ident!( $($args:tt)* )) => { ... };
    ($input:expr, $f:expr) => { ... };
}

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""[..])));