aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnreal Hoang <[email protected]>2019-05-16 04:56:54 +0100
committerUnreal Hoang <[email protected]>2019-05-21 15:31:57 +0100
commit079ed6011a1febafef4bcb209c7433a415642d19 (patch)
tree8eb6e5f80a48b024f9545140588945f5589a43d2
parent08e954f0fd35f4f5f847dba7921d48dc4aa669c0 (diff)
add feature doc
-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✨