Skip to content

Commit 787b270

Browse files
committed
Move const tests for Result to library\core
Part of rust-lang#76268
1 parent 518f1cc commit 787b270

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

library/core/tests/result.rs

+16
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,19 @@ fn test_result_as_deref_mut() {
305305
let expected_result = Result::Err::<&mut u32, &mut Vec<i32>>(&mut expected_vec);
306306
assert_eq!(mut_err.as_deref_mut(), expected_result);
307307
}
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

-12
This file was deleted.

0 commit comments

Comments
 (0)