From 91e482b46d43a24cd0a48ea1119b93105140cff2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 27 Mar 2020 12:12:17 +0100 Subject: Replace if with if-let --- docs/user/assists.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'docs/user') diff --git a/docs/user/assists.md b/docs/user/assists.md index f3ce6b0e0..3b7467a26 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md @@ -583,6 +583,29 @@ fn handle(action: Action) { } ``` +## `replace_let_with_if_let` + +Replaces `if let` with an else branch with a `match` expression. + +```rust +// BEFORE + +fn main(action: Action) { + ┃let x = compute(); +} + +fn compute() -> Option { None } + +// AFTER + +fn main(action: Action) { + if let Some(x) = compute() { + } +} + +fn compute() -> Option { None } +``` + ## `replace_qualified_name_with_use` Adds a use statement for a given fully-qualified name. -- cgit v1.2.3