]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-nonzero.rs
New upstream version 1.47.0+dfsg1
[rustc.git] / src / test / ui / consts / const-nonzero.rs
1 // run-pass
2
3 use std::num::NonZeroU8;
4
5 const X: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(5) };
6 const Y: u8 = X.get();
7
8 const ZERO: Option<NonZeroU8> = NonZeroU8::new(0);
9 const ONE: Option<NonZeroU8> = NonZeroU8::new(1);
10
11 fn main() {
12 assert_eq!(Y, 5);
13
14 assert!(ZERO.is_none());
15 assert_eq!(ONE.unwrap().get(), 1);
16 }