nom::take_while1_s! [] [src]

macro_rules! take_while1_s {
    ($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 ```

#[macro_use] extern crate nom;

use nom::IResult::Done;

use nom::is_alphanumeric;

fn main() {

fn alphabetic(chr: char) -> bool { (chr >= 0x41 as char && chr <= 0x5A as char) || (chr >= 0x61 as char && chr <= 0x7A as char) } named!( alpha<&str,&str>, take_while1_s!( alphabetic ) );

let r = alpha("abcd\nefgh"); assert_eq!(r, Done("\nefgh", "abcd"));

}