aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/handlers
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-24 12:01:56 +0100
committerGitHub <[email protected]>2020-08-24 12:01:56 +0100
commitb00702b738ced5218916658aecdb1d105f38e788 (patch)
treef8fdf0a97e0e8c81cf0898d86a1ff65471f23d76 /crates/assists/src/handlers
parent951c7c157af1c70392492ab1bfd6fb291d2ffefb (diff)
parent1d129a7172bbe502182be6cc3b50b3250cb6f3a9 (diff)
Merge #5851
5851: Invert if should be smart about is_some, is_none, is_ok, is_err r=matklad a=dragfire Fixes #5827 Co-authored-by: dragfire <[email protected]>
Diffstat (limited to 'crates/assists/src/handlers')
-rw-r--r--crates/assists/src/handlers/invert_if.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/assists/src/handlers/invert_if.rs b/crates/assists/src/handlers/invert_if.rs
index f0e047538..294256297 100644
--- a/crates/assists/src/handlers/invert_if.rs
+++ b/crates/assists/src/handlers/invert_if.rs
@@ -106,4 +106,22 @@ mod tests {
106 "fn f() { i<|>f let Some(_) = Some(1) { 1 } else { 0 } }", 106 "fn f() { i<|>f let Some(_) = Some(1) { 1 } else { 0 } }",
107 ) 107 )
108 } 108 }
109
110 #[test]
111 fn invert_if_option_case() {
112 check_assist(
113 invert_if,
114 "fn f() { if<|> doc_style.is_some() { Class::DocComment } else { Class::Comment } }",
115 "fn f() { if doc_style.is_none() { Class::Comment } else { Class::DocComment } }",
116 )
117 }
118
119 #[test]
120 fn invert_if_result_case() {
121 check_assist(
122 invert_if,
123 "fn f() { i<|>f doc_style.is_err() { Class::Err } else { Class::Ok } }",
124 "fn f() { if doc_style.is_ok() { Class::Ok } else { Class::Err } }",
125 )
126 }
109} 127}