Function glue::combinators::structures::separated

source ยท
pub fn separated<'a, Lhs, LhsRes, Sep, SepRes, Rhs, RhsRes>(
    left: Lhs,
    separator: Sep,
    right: Rhs,
) -> impl Parser<'a, (LhsRes, RhsRes)>
where Lhs: Parser<'a, LhsRes>, Sep: Parser<'a, SepRes>, Rhs: Parser<'a, RhsRes>,
Expand description

Match a structure that consists of two parsers separated by another.

assert_eq!(
    separated(is(digit), is(one_of("+-")), is(digit)).parse("1+2"),
    Ok((
        ParserContext {
            input: "1+2",
            bounds: 2..3,
        },
        ("1", "2"),
    ))
);