File tree 1 file changed +31
-2
lines changed
1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -390,14 +390,14 @@ fn foo() {
390
390
391
391
- Move guard expression to match arm body
392
392
``` rust
393
- // before:
393
+ // before:
394
394
fn f () {
395
395
match x {
396
396
<| >y @ 4 | y @ 5 if y > 5 => true ,
397
397
_ => false
398
398
}
399
399
}
400
- // after:
400
+ // after:
401
401
fn f () {
402
402
match x {
403
403
y @ 4 | y @ 5 => if y > 5 { <| >true },
@@ -406,6 +406,35 @@ fn f() {
406
406
}
407
407
```
408
408
409
+ - Move if condition to match arm guard
410
+ ``` rust
411
+ // before:
412
+ fn f () {
413
+ let mut t = 'a' ;
414
+ let chars = " abcd" ;
415
+ match t {
416
+ '\ r ' => if chars . clone (). next (). is_some () {
417
+ t = 'e' ;<| >
418
+ false
419
+ },
420
+ _ => true
421
+ }
422
+ }
423
+
424
+ // after:
425
+ fn f () {
426
+ let mut t = 'a' ;
427
+ let chars = " abcd" ;
428
+ match t {
429
+ '\ r ' <| >if chars . clone (). next (). is_some () => {
430
+ t = 'e' ;
431
+ false
432
+ },
433
+ _ => true
434
+ }
435
+ }
436
+ ```
437
+
409
438
### Magic Completions
410
439
411
440
In addition to usual reference completion, rust-analyzer provides some ✨magic✨
You can’t perform that action at this time.
0 commit comments