]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-nonzero.rs
Rollup merge of #72279 - RalfJung:raw-ref-macros, r=nikomatsakis
[rust.git] / src / test / ui / consts / const-nonzero.rs
1 // run-pass
2
3 #![feature(const_nonzero_int_methods)]
4
5 use std::num::NonZeroU8;
6
7 const X: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(5) };
8 const Y: u8 = X.get();
9
10 const ZERO: Option<NonZeroU8> = NonZeroU8::new(0);
11 const ONE: Option<NonZeroU8> = NonZeroU8::new(1);
12
13 fn main() {
14     assert_eq!(Y, 5);
15
16     assert!(ZERO.is_none());
17     assert_eq!(ONE.unwrap().get(), 1);
18 }