I want to achieve something like I'm doing with the | syntax.
enum Foo {
Something,
SomethingElse,
Whatever,
}
fn bar(x: Foo) {
let valids = vec![Something, SomethingElse];
match x {
Something | SomethingElse => println!("Something..."),
_ => println!("Whatever"),
}
}
But the multiple pattern I want to match against are defined in a Vec<Foo> which is known at compile time, I don't want to have duplicates declarations.
fn bar(x: Foo, valids: Vec<Foo>) {
match x {
/* Enum type inside valids */ => println!("Valid"),
_ => println!("Not valid"),
}
}
Is it possible ?