diff options
Diffstat (limited to 'docs/user')
-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 f3ce6b0e0..b2568a954 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -597,6 +597,29 @@ use std::collections::HashMap; | |||
597 | fn process(map: HashMap<String, String>) {} | 597 | fn process(map: HashMap<String, String>) {} |
598 | ``` | 598 | ``` |
599 | 599 | ||
600 | ## `replace_unwrap_with_match` | ||
601 | |||
602 | Replaces `unwrap` a `match` expression. Works for Result and Option. | ||
603 | |||
604 | ```rust | ||
605 | // BEFORE | ||
606 | enum Result<T, E> { Ok(T), Err(E) } | ||
607 | fn main() { | ||
608 | let x: Result<i32, i32> = Result::Ok(92); | ||
609 | let y = x.┃unwrap(); | ||
610 | } | ||
611 | |||
612 | // AFTER | ||
613 | enum Result<T, E> { Ok(T), Err(E) } | ||
614 | fn main() { | ||
615 | let x: Result<i32, i32> = Result::Ok(92); | ||
616 | let y = match x { | ||
617 | Ok(a) => a, | ||
618 | _ => unreachable!(), | ||
619 | }; | ||
620 | } | ||
621 | ``` | ||
622 | |||
600 | ## `split_import` | 623 | ## `split_import` |
601 | 624 | ||
602 | Wraps the tail of import into braces. | 625 | Wraps the tail of import into braces. |