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 2c7cfb9 commit eeb9031Copy full SHA for eeb9031
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
+}
0 commit comments