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.
Option
library\core
1 parent 9486f72 commit 4f859fbCopy full SHA for 4f859fb
library/core/tests/option.rs
@@ -356,3 +356,19 @@ fn test_replace() {
356
assert_eq!(x, Some(3));
357
assert_eq!(old, None);
358
}
359
+
360
+#[test]
361
+fn option_const() {
362
+ // test that the methods of `Option` are usable in a const context
363
364
+ const OPTION: Option<usize> = Some(32);
365
366
+ const REF: Option<&usize> = OPTION.as_ref();
367
+ assert_eq!(REF, Some(&32));
368
369
+ const IS_SOME: bool = OPTION.is_some();
370
+ assert!(IS_SOME);
371
372
+ const IS_NONE: bool = OPTION.is_none();
373
+ assert!(!IS_NONE);
374
+}
src/test/ui/consts/const-option.rs
0 commit comments