Function nom::sequence::tuple

source · []
pub fn tuple<I, O, E: ParseError<I>, List: Tuple<I, O, E>>(
    l: List
) -> impl FnMut(I) -> IResult<I, O, E>
Expand description

Applies a tuple of parsers one by one and returns their results as a tuple.

use nom::sequence::tuple;
use nom::character::complete::{alpha1, digit1};
let mut parser = tuple((alpha1, digit1, alpha1));

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