That's not really a solution, isn't it? Part of the problem is that I also need to use the _ pattern and treat that in some way, even if it is impossible to have other patterns except Bar and Baz in the nested match.
As I said, it is a contrived example. I can rewrite it like this, and still have the same problem, only now it is even less clear at a glance that I am expecting only certain patterns:
enum Example {
Foo,
Bar,
Baz
}
fn handle_bar_or_baz(e: Example) {
println!("Common code");
match e {
Example::Bar => println!("Bar"),
Example::Baz => println!("Baz"),
_ => panic!()
}
}
fn example(e: Example) {
match e {
Example::Foo => handle_foo(),
Example::Bar | Example::Baz => {
handle_bar_or_baz(e)
}
}
}