File tree 2 files changed +24
-22
lines changed
2 files changed +24
-22
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,22 @@ use crate::{
8
8
assist_context:: { AssistContext , Assists } ,
9
9
AssistId , AssistKind ,
10
10
} ;
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
+ // ```
27
27
pub ( crate ) fn merge_nested_if ( acc : & mut Assists , ctx : & AssistContext < ' _ > ) -> Option < ( ) > {
28
28
let if_keyword = ctx. find_token_syntax_at_offset ( T ! [ if ] ) ?;
29
29
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() {
2056
2056
check_doc_test (
2057
2057
"merge_nested_if" ,
2058
2058
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
+ "##### ,
2062
2063
r#####"
2063
- fn main() {
2064
- if x == 3 && y == 4 { 1 }
2065
- }"##### ,
2064
+ fn main() {
2065
+ if x == 3 && y == 4 { 1 }
2066
+ }
2067
+ "##### ,
2066
2068
)
2067
2069
}
2068
2070
You can’t perform that action at this time.
0 commit comments