Skip to content

Commit 8285e19

Browse files
committed
add feature doc
1 parent a4416ac commit 8285e19

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

docs/user/features.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,14 @@ fn foo() {
390390

391391
- Move guard expression to match arm body
392392
```rust
393-
//before:
393+
// before:
394394
fn f() {
395395
match x {
396396
<|>y @ 4 | y @ 5 if y > 5 => true,
397397
_ => false
398398
}
399399
}
400-
//after:
400+
// after:
401401
fn f() {
402402
match x {
403403
y @ 4 | y @ 5 => if y > 5 { <|>true },
@@ -406,6 +406,35 @@ fn f() {
406406
}
407407
```
408408

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 let Some(_) = chars.clone().next() {
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 let Some(_) = chars.clone().next() => {
430+
t = 'e';
431+
false
432+
},
433+
_ => true
434+
}
435+
}
436+
```
437+
409438
### Magic Completions
410439

411440
In addition to usual reference completion, rust-analyzer provides some ✨magic✨

0 commit comments

Comments
 (0)