-
|
Hey! Thanks for Is it possible to simplify a parser like the following? I'm not familiar with implementing variadic arguments using tuples, so I'm not sure where to even start. fn parse<'a>() -> impl Parser<'a, &'a str, Self> {
group((
number(),
arg_sep(),
number(),
arg_sep(),
number(),
arg_sep(),
number(),
arg_sep(),
bool(),
arg_sep(),
bool(),
arg_sep(),
color(),
))
.map_group(|a, _, b, _, c, _, d, _, e, _, f, _, g| Self::new(a, b, c, d, e, f, g))
}Ideally, this new parser fn parse<'a>() -> impl Parser<'a, &'a str, Self> {
arg_group((
number(),
number(),
number(),
number(),
bool(),
bool(),
color(),
))
.map_group(Self::new)
} |
Beta Was this translation helpful? Give feedback.
Answered by
zesterer
Sep 7, 2025
Replies: 1 comment 1 reply
-
|
You can do: let num_sep = number().then_ignore(arg_sep());
group((num_sep, num_sep, num_sep, ...))Alternatively, if you want to accept any number of them, number().separated_by(arg_sep()).collect::<Vec<_>>() |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
SkyLeite
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do:
Alternatively, if you want to accept any number of them,