Macro nom::separated_pair[][src]

macro_rules! separated_pair {
    ($i : expr, $submac : ident! ($($args : tt) *), $($rest : tt) *) => { ... };
    ($i : expr, $f : expr, $submac : ident! ($($args : tt) *), $($rest : tt) *) => { ... };
    ($i : expr, $f : expr, $g : expr, $submac : ident! ($($args : tt) *)) => { ... };
    ($i : expr, $f : expr, $g : expr, $h : expr) => { ... };
}
Expand description

separated_pair!(I -> IResult<I,O>, I -> IResult<I, T>, I -> IResult<I,P>) => I -> IResult<I, (O,P)> separated_pair(X,sep,Y) returns a tuple of its first and third child parsers if all 3 succeed

named!(parser<&str, (&str, &str)>, separated_pair!(alpha1, char!(','), digit1));

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