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