We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
NonZeroU8::new
1 parent 0b20ce9 commit 0755c41Copy full SHA for 0755c41
src/test/ui/consts/const-nonzero.rs
@@ -1,9 +1,18 @@
1
-// build-pass (FIXME(62277): could be check-pass?)
+// 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
}
0 commit comments