From 3bf076e76b2afde77f1c0d2c763cef32407f0465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 23 Mar 2021 21:27:38 +0100 Subject: [PATCH] Add test for Result::into_err --- library/core/tests/result.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs index 5fcd7b4d3a327..c461ab380ad3d 100644 --- a/library/core/tests/result.rs +++ b/library/core/tests/result.rs @@ -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 { + Err(666) + } + + assert_eq!(until_error_op().into_err(), 666); + + enum MyNeverToken {} + impl From for ! { + fn from(never: MyNeverToken) -> ! { + match never {} + } + } + + fn until_error_op2() -> Result { + Err(667) + } + + assert_eq!(until_error_op2().into_err(), 667); +} + #[test] fn test_try() { fn try_result_some() -> Option {