I would expect the Rust compiler to complain about the missing cases in match as well as the unknown identifier:
pub enum MyEnum {
Case1,
Case2,
}
impl MyEnum {
fn my_func(&self) {
match self {
_whatever_string => println!("Why am I printed ?"),
}
}
}
fn main() {
let x = MyEnum::Case1;
x.my_func();
}
Why does it compile and call the println
?