Macro nom::many1_count[][src]

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

many1_count!(I -> IResult<I,O>) => I -> IResult<I, usize> Applies the parser 1 or more times and returns the number of times the parser was applied.

#[macro_use] extern crate nom;
use nom::character::streaming::digit1;

named!(number<&[u8], usize>, many1_count!(pair!(digit1, tag!(","))));

fn main() {
    assert_eq!(number(&b"123,45,abc"[..]), Ok((&b"abc"[..], 2)));
}