[−][src]Function gchemol_parser::parsers::pair
pub fn pair<I, O1, O2, E, F, G>(first: F, second: G) -> impl Fn(I) where
E: ParseError<I>,
F: Fn(I) -> Result<(I, O1), Err<E>>,
G: Fn(I) -> Result<(I, O2), Err<E>>,
Gets an object from the first parser, then gets another object from the second parser.
Arguments
first
The first parser to apply.second
The second parser to apply.
use nom::sequence::pair; use nom::bytes::complete::tag; let parser = pair(tag("abc"), tag("efg")); assert_eq!(parser("abcefg"), Ok(("", ("abc", "efg")))); assert_eq!(parser("abcefghij"), Ok(("hij", ("abc", "efg")))); assert_eq!(parser(""), Err(Err::Error(("", ErrorKind::Tag)))); assert_eq!(parser("123"), Err(Err::Error(("123", ErrorKind::Tag))));