3 ms·
It's not just typical, it's required. If you add a default match when you've already specified all the possible cases, the compiler gives you an error. Here's a
by geofft 10y ago
It's not just typical, it's required. If you add a default match when you've already specified all the possible cases, the compiler gives you an error. Here's an example (https://is.gd/KjSc8B https://is.gd/KjSc8B):
enum Foo {
Bar(i32),
Baz(i32),
}
fn matchfoo(f: Foo) -> i32 {
match f {
Foo::Bar(x) => x,
Foo::Baz(x) => x,
_ => 42
}
}
gives "unreachable pattern", a hard error, for the "_" case.