Function separated_pair

fn separated_pair<I, O1, O2, E: ParseError<I>, F, G, H>(first: F, sep: G, second: H) -> impl Parser<I, Output = (O1, O2), Error = E>
where
    F: Parser<I, Output = O1, Error = E>,
    G: Parser<I, Error = E>,
    H: Parser<I, Output = O2, Error = E>

Gets an object from the first parser, then matches an object from the sep_parser and discards it, then gets another object from the second parser.

Arguments

# use nom::{Err, error::ErrorKind, Needed, Parser};
# use nom::Needed::Size;
use nom::sequence::separated_pair;
use nom::bytes::complete::tag;

let mut parser = separated_pair(tag("abc"), tag("|"), tag("efg"));

assert_eq!(parser.parse("abc|efg"), Ok(("", ("abc", "efg"))));
assert_eq!(parser.parse("abc|efghij"), Ok(("hij", ("abc", "efg"))));
assert_eq!(parser.parse(""), Err(Err::Error(("", ErrorKind::Tag))));
assert_eq!(parser.parse("123"), Err(Err::Error(("123", ErrorKind::Tag))));