aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/user/assists.md23
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;
620fn process(map: HashMap<String, String>) {} 620fn process(map: HashMap<String, String>) {}
621``` 621```
622 622
623## `replace_unwrap_with_match`
624
625Replaces `unwrap` a `match` expression. Works for Result and Option.
626
627```rust
628// BEFORE
629enum Result<T, E> { Ok(T), Err(E) }
630fn main() {
631 let x: Result<i32, i32> = Result::Ok(92);
632 let y = x.┃unwrap();
633}
634
635// AFTER
636enum Result<T, E> { Ok(T), Err(E) }
637fn 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
625Wraps the tail of import into braces. 648Wraps the tail of import into braces.