diff options
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 3b7467a26..2495af20a 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -620,6 +620,29 @@ use std::collections::HashMap; | |||
620 | fn process(map: HashMap<String, String>) {} | 620 | fn process(map: HashMap<String, String>) {} |
621 | ``` | 621 | ``` |
622 | 622 | ||
623 | ## `replace_unwrap_with_match` | ||
624 | |||
625 | Replaces `unwrap` a `match` expression. Works for Result and Option. | ||
626 | |||
627 | ```rust | ||
628 | // BEFORE | ||
629 | enum Result<T, E> { Ok(T), Err(E) } | ||
630 | fn main() { | ||
631 | let x: Result<i32, i32> = Result::Ok(92); | ||
632 | let y = x.┃unwrap(); | ||
633 | } | ||
634 | |||
635 | // AFTER | ||
636 | enum Result<T, E> { Ok(T), Err(E) } | ||
637 | fn main() { | ||
638 | let x: Result<i32, i32> = Result::Ok(92); | ||
639 | let y = match x { | ||
640 | Ok(a) => a, | ||
641 | _ => unreachable!(), | ||
642 | }; | ||
643 | } | ||
644 | ``` | ||
645 | |||
623 | ## `split_import` | 646 | ## `split_import` |
624 | 647 | ||
625 | Wraps the tail of import into braces. | 648 | Wraps the tail of import into braces. |