rust/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs

20 lines
378 B
Rust
Raw Normal View History

// run-pass
2017-11-03 14:15:15 -05:00
#![feature(non_exhaustive)]
#[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",
};
}