File tree Expand file tree Collapse file tree 2 files changed +24
-22
lines changed Expand file tree Collapse file tree 2 files changed +24
-22
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,22 @@ use crate::{
88 assist_context:: { AssistContext , Assists } ,
99 AssistId , AssistKind ,
1010} ;
11- /// Assist: merge_nested_if
12- ///
13- /// This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}`
14- /// This assist can only be applied with the cursor on `if`.
15- ///
16- /// ```
17- /// fn main() {
18- /// i$0f x == 3 { if y == 4 { 1 } }
19- /// }
20- /// ```
21- /// ->
22- /// ```
23- /// fn main() {
24- /// if x == 3 && y == 4 { 1 }
25- /// }
26- /// ```
11+ // Assist: merge_nested_if
12+ //
13+ // This transforms if expressions of the form `if x { if y {A} }` into `if x && y {A}`
14+ // This assist can only be applied with the cursor on `if`.
15+ //
16+ // ```
17+ // fn main() {
18+ // i$0f x == 3 { if y == 4 { 1 } }
19+ // }
20+ // ```
21+ // ->
22+ // ```
23+ // fn main() {
24+ // if x == 3 && y == 4 { 1 }
25+ // }
26+ // ```
2727pub ( crate ) fn merge_nested_if ( acc : & mut Assists , ctx : & AssistContext < ' _ > ) -> Option < ( ) > {
2828 let if_keyword = ctx. find_token_syntax_at_offset ( T ! [ if ] ) ?;
2929 let expr = ast:: IfExpr :: cast ( if_keyword. parent ( ) ?) ?;
Original file line number Diff line number Diff line change @@ -2056,13 +2056,15 @@ fn doctest_merge_nested_if() {
20562056 check_doc_test (
20572057 "merge_nested_if" ,
20582058 r#####"
2059- fn main() {
2060- i$0f x == 3 { if y == 4 { 1 } }
2061- }"##### ,
2059+ fn main() {
2060+ i$0f x == 3 { if y == 4 { 1 } }
2061+ }
2062+ "##### ,
20622063 r#####"
2063- fn main() {
2064- if x == 3 && y == 4 { 1 }
2065- }"##### ,
2064+ fn main() {
2065+ if x == 3 && y == 4 { 1 }
2066+ }
2067+ "##### ,
20662068 )
20672069}
20682070
You can’t perform that action at this time.
0 commit comments