rust/tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.rs

12 lines
287 B
Rust
Raw Normal View History

2021-11-26 21:27:40 -06:00
// aux-build:enums.rs
extern crate enums;
use enums::FieldLessWithNonExhaustiveVariant;
fn main() {
let e = FieldLessWithNonExhaustiveVariant::default();
let d = e as u8; //~ ERROR casting `FieldLessWithNonExhaustiveVariant` as `u8` is invalid [E0606]
2021-11-26 21:27:40 -06:00
assert_eq!(d, 0);
}