[][src]Macro nom::take_while1

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

take_while1!(T -> bool) => &[T] -> IResult<&[T], &[T]> returns the longest (non empty) list of bytes until the provided function fails.

The argument is either a function &[T] -> bool or a macro returning a bool

Example

 named!( alpha, take_while1!( is_alphanumeric ) );

 let r = alpha(&b"abcd\nefgh"[..]);
 assert_eq!(r, Ok((&b"\nefgh"[..], &b"abcd"[..])));
 let r = alpha(&b"\nefgh"[..]);
 assert_eq!(r, Err(Err::Error(error_position!(&b"\nefgh"[..], ErrorKind::TakeWhile1))));