Function winnow::sequence::pair

source ·
pub fn pair<I, O1, O2, E: ParseError<I>, F, G>(
    first: F,
    second: G
) -> impl FnMut(I) -> IResult<I, (O1, O2), E>where
    F: Parser<I, O1, E>,
    G: Parser<I, O2, E>,
👎Deprecated since 0.1.0: <code>Parser</code> is directly implemented for tuples
Expand description

Gets an object from the first parser, then gets another object from the second parser.

WARNING: Deprecated, Parser is directly implemented for tuples

Arguments

  • first The first parser to apply.
  • second The second parser to apply.
use winnow::sequence::pair;
use winnow::bytes::tag;

let mut 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(ErrMode::Backtrack(Error::new("", ErrorKind::Tag))));
assert_eq!(parser("123"), Err(ErrMode::Backtrack(Error::new("123", ErrorKind::Tag))));