rust/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate.rs

19 lines
351 B
Rust

//@ run-pass
#[non_exhaustive]
pub enum NonExhaustiveEnum {
Unit,
Tuple(u32),
Struct { field: u32 }
}
fn main() {
let enum_unit = NonExhaustiveEnum::Unit;
match enum_unit {
NonExhaustiveEnum::Unit => "first",
NonExhaustiveEnum::Tuple(_) => "second",
NonExhaustiveEnum::Struct { .. } => "third",
};
}