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.
Result
library\core
1 parent 518f1cc commit 787b270Copy full SHA for 787b270
library/core/tests/result.rs
@@ -305,3 +305,19 @@ fn test_result_as_deref_mut() {
305
let expected_result = Result::Err::<&mut u32, &mut Vec<i32>>(&mut expected_vec);
306
assert_eq!(mut_err.as_deref_mut(), expected_result);
307
}
308
+
309
+#[test]
310
+fn result_const() {
311
+ // test that the methods of `Result` are usable in a const context
312
313
+ const RESULT: Result<usize, bool> = Ok(32);
314
315
+ const REF: Result<&usize, &bool> = RESULT.as_ref();
316
+ assert_eq!(REF, Ok(&32));
317
318
+ const IS_OK: bool = RESULT.is_ok();
319
+ assert!(IS_OK);
320
321
+ const IS_ERR: bool = RESULT.is_err();
322
+ assert!(!IS_ERR)
323
+}
src/test/ui/consts/const-result.rs
0 commit comments