Macro nom::pair[][src]

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

pair!(I -> IResult<I,O>, I -> IResult<I,P>) => I -> IResult<I, (O,P)> pair returns a tuple of the results of its two child parsers of both succeed

named!(parser<&str, (&str, &str)>, pair!(alpha1, digit1));

assert_eq!(parser("abc123"), Ok(("", ("abc", "123"))));
assert_eq!(parser("123abc"), Err(Err::Error(("123abc", ErrorKind::Alpha))));
assert_eq!(parser("abc;123"), Err(Err::Error((";123", ErrorKind::Digit))));