From d9df0f43ac669a68dc76466a2f2c21885b5af2dd Mon Sep 17 00:00:00 2001 From: Unreal Hoang Date: Thu, 26 Mar 2020 18:16:10 +0900 Subject: Assist: replace unwrap with match --- crates/ra_assists/src/doc_tests/generated.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/ra_assists/src/doc_tests') diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs index 62dcb3808..543224232 100644 --- a/crates/ra_assists/src/doc_tests/generated.rs +++ b/crates/ra_assists/src/doc_tests/generated.rs @@ -622,6 +622,30 @@ fn process(map: HashMap) {} ) } +#[test] +fn doctest_replace_unwrap_with_match() { + check( + "replace_unwrap_with_match", + r#####" +enum Result { Ok(T), Err(E) } +fn main() { + let x: Result = Result::Ok(92); + let y = x.<|>unwrap(); +} +"#####, + r#####" +enum Result { Ok(T), Err(E) } +fn main() { + let x: Result = Result::Ok(92); + let y = match x { + Ok(a) => a, + _ => unreachable!(), + }; +} +"#####, + ) +} + #[test] fn doctest_split_import() { check( -- cgit v1.2.3