2018-09-06 12:41:12 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_unsafe)]
|
2018-09-06 12:41:12 +00:00
|
|
|
|
2018-02-19 09:26:53 +00:00
|
|
|
// https://github.com/rust-lang/rust/issues/48279
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq)]
|
|
|
|
pub struct NonZeroU32 {
|
|
|
|
value: u32
|
|
|
|
}
|
|
|
|
|
|
|
|
impl NonZeroU32 {
|
|
|
|
const unsafe fn new_unchecked(value: u32) -> Self {
|
|
|
|
NonZeroU32 { value }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-22 13:59:52 +00:00
|
|
|
// pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(7) };
|
2018-02-19 09:26:53 +00:00
|
|
|
pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32 { value: 7 } };
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
match None {
|
|
|
|
Some(FOO_ATOM) => {}
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|