From 3126152a84e08a80659d49d735d03628154564ed Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Oct 2019 17:37:04 +0300 Subject: document a couple of assists --- docs/user/assists.md | 37 +++++++++++++++++++++++++++++++++++++ docs/user/features.md | 51 --------------------------------------------------- 2 files changed, 37 insertions(+), 51 deletions(-) (limited to 'docs/user') diff --git a/docs/user/assists.md b/docs/user/assists.md index eeb486832..7a64c80ad 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md @@ -137,6 +137,18 @@ fn main() { } ``` +## `change_visibility` + +Adds or changes existing visibility specifier. + +```rust +// BEFORE +fn<|> frobnicate() {} + +// AFTER +pub(crate) fn frobnicate() {} +``` + ## `convert_to_guarded_return` Replace a large conditional with a guarded return. @@ -159,3 +171,28 @@ fn main() { bar(); } ``` + +## `fill_match_arms` + +Adds missing clauses to a `match` expression. + +```rust +// BEFORE +enum Action { Move { distance: u32 }, Stop } + +fn handle(action: Action) { + match action { + <|> + } +} + +// AFTER +enum Action { Move { distance: u32 }, Stop } + +fn handle(action: Action) { + match action { + Action::Move{ distance } => (), + Action::Stop => (), + } +} +``` diff --git a/docs/user/features.md b/docs/user/features.md index acf092cec..39dab710d 100644 --- a/docs/user/features.md +++ b/docs/user/features.md @@ -118,57 +118,6 @@ impl Debug<|> for Foo { } ``` -- Change Visibility - -```rust -// before: -<|>fn foo() {} - -// after: -<|>pub(crate) fn foo() {} - -// after: -<|>pub fn foo() {} -``` - -- Fill match arms - -```rust -// before: -enum A { - As, - Bs, - Cs(String), - Ds(String, String), - Es{x: usize, y: usize} -} - -fn main() { - let a = A::As; - match a<|> {} -} - -// after: -enum A { - As, - Bs, - Cs(String), - Ds(String, String), - Es{x: usize, y: usize} -} - -fn main() { - let a = A::As; - match <|>a { - A::As => (), - A::Bs => (), - A::Cs(_) => (), - A::Ds(_, _) => (), - A::Es{x, y} => (), - } -} -``` - - Fill struct fields ```rust -- cgit v1.2.3