Is it possible to repeat something n times based on the number of arguments without using the actual argument? My usecase would be to implement an Enum variant, that takes 1 or more type params as well as an implementation that matches the enum variant using wildcards. So the number of wildcards will depend on the number of arguments provided.
Example:
macro_rules! impl_enum {
($name: ident, $($params: ty)+, $val:expr) => {
enum MyEnum {
$name($($params)+,)
}
impl MyEnum {
fn get_val(self) {
match self {
MyEnum::$name(??????) => $val
}
}
}
}
}
Now I would like the output of
impl_enum!(Variant1, Type1 Type2 Type3, 42);
to be
enum MyEnum {
Variant1(Type1, Type2, Type3),
}
impl MyEnum {
fn get_val(self) {
match self {
MyEnum::Variant1(_,_,_) => 42,
}
}
}
Is this possible?