Skip to content

Commit

Permalink
Add test for Result::into_err
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Mar 23, 2021
1 parent 593f929 commit 3bf076e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions library/core/tests/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,28 @@ pub fn test_into_ok() {
assert_eq!(infallible_op2().into_ok(), 667);
}

#[test]
pub fn test_into_err() {
fn until_error_op() -> Result<!, isize> {
Err(666)
}

assert_eq!(until_error_op().into_err(), 666);

enum MyNeverToken {}
impl From<MyNeverToken> for ! {
fn from(never: MyNeverToken) -> ! {
match never {}
}
}

fn until_error_op2() -> Result<MyNeverToken, isize> {
Err(667)
}

assert_eq!(until_error_op2().into_err(), 667);
}

#[test]
fn test_try() {
fn try_result_some() -> Option<u8> {
Expand Down

0 comments on commit 3bf076e

Please sign in to comment.