aboutsummaryrefslogtreecommitdiff
path: root/docs/user
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-22 08:39:54 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-22 08:39:54 +0100
commit67d5927b160aa5ec66fb6dae5d7075ebb509066f (patch)
tree1876de2eeab5c56d2579b5b0cdfa4789ec263200 /docs/user
parent4199f4e2c31ececbf10e4bc620a7a1ea98b55f78 (diff)
parent079ed6011a1febafef4bcb209c7433a415642d19 (diff)
Merge #1281
1281: Move arm cond to match guard r=matklad a=unrealhoang I did split the rename to another commit, yet Github UI still show entirely new file change. Please review using commits. Co-authored-by: Unreal Hoang <[email protected]>
Diffstat (limited to 'docs/user')
-rw-r--r--docs/user/features.md33
1 files changed, 31 insertions, 2 deletions
diff --git a/docs/user/features.md b/docs/user/features.md
index a714574fb..22470bc56 100644
--- a/docs/user/features.md
+++ b/docs/user/features.md
@@ -390,14 +390,14 @@ fn foo() {
390 390
391- Move guard expression to match arm body 391- Move guard expression to match arm body
392```rust 392```rust
393//before: 393// before:
394fn f() { 394fn f() {
395 match x { 395 match x {
396 <|>y @ 4 | y @ 5 if y > 5 => true, 396 <|>y @ 4 | y @ 5 if y > 5 => true,
397 _ => false 397 _ => false
398 } 398 }
399} 399}
400//after: 400// after:
401fn f() { 401fn f() {
402 match x { 402 match x {
403 y @ 4 | y @ 5 => if y > 5 { <|>true }, 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:
412fn 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:
425fn 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### Magic Completions 438### Magic Completions
410 439
411In addition to usual reference completion, rust-analyzer provides some ✨magic✨ 440In addition to usual reference completion, rust-analyzer provides some ✨magic✨