diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-27 11:21:57 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-27 11:21:57 +0000 |
commit | a4901fdcfd5ef056adc3b1999582e6322e911dbd (patch) | |
tree | 97c4920c8f89416795311429955d9801799a58bb /docs | |
parent | f9cf86475c042a41f2e3b59baf96b456e0ff521b (diff) | |
parent | 91e482b46d43a24cd0a48ea1119b93105140cff2 (diff) |
Merge #3742
3742: Replace if with if-let r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user/assists.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/user/assists.md b/docs/user/assists.md index b2568a954..2495af20a 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -583,6 +583,29 @@ fn handle(action: Action) { | |||
583 | } | 583 | } |
584 | ``` | 584 | ``` |
585 | 585 | ||
586 | ## `replace_let_with_if_let` | ||
587 | |||
588 | Replaces `if let` with an else branch with a `match` expression. | ||
589 | |||
590 | ```rust | ||
591 | // BEFORE | ||
592 | |||
593 | fn main(action: Action) { | ||
594 | ┃let x = compute(); | ||
595 | } | ||
596 | |||
597 | fn compute() -> Option<i32> { None } | ||
598 | |||
599 | // AFTER | ||
600 | |||
601 | fn main(action: Action) { | ||
602 | if let Some(x) = compute() { | ||
603 | } | ||
604 | } | ||
605 | |||
606 | fn compute() -> Option<i32> { None } | ||
607 | ``` | ||
608 | |||
586 | ## `replace_qualified_name_with_use` | 609 | ## `replace_qualified_name_with_use` |
587 | 610 | ||
588 | Adds a use statement for a given fully-qualified name. | 611 | Adds a use statement for a given fully-qualified name. |