diff options
author | Aleksey Kladov <[email protected]> | 2019-10-26 15:37:04 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-26 15:37:55 +0100 |
commit | 3126152a84e08a80659d49d735d03628154564ed (patch) | |
tree | d6a146298f38feeca9a1710118f92118f4f0fd38 /docs | |
parent | 394e4744792f8e36ca1690cb23c2d3dd55556272 (diff) |
document a couple of assists
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user/assists.md | 37 | ||||
-rw-r--r-- | docs/user/features.md | 51 |
2 files changed, 37 insertions, 51 deletions
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() { | |||
137 | } | 137 | } |
138 | ``` | 138 | ``` |
139 | 139 | ||
140 | ## `change_visibility` | ||
141 | |||
142 | Adds or changes existing visibility specifier. | ||
143 | |||
144 | ```rust | ||
145 | // BEFORE | ||
146 | fn<|> frobnicate() {} | ||
147 | |||
148 | // AFTER | ||
149 | pub(crate) fn frobnicate() {} | ||
150 | ``` | ||
151 | |||
140 | ## `convert_to_guarded_return` | 152 | ## `convert_to_guarded_return` |
141 | 153 | ||
142 | Replace a large conditional with a guarded return. | 154 | Replace a large conditional with a guarded return. |
@@ -159,3 +171,28 @@ fn main() { | |||
159 | bar(); | 171 | bar(); |
160 | } | 172 | } |
161 | ``` | 173 | ``` |
174 | |||
175 | ## `fill_match_arms` | ||
176 | |||
177 | Adds missing clauses to a `match` expression. | ||
178 | |||
179 | ```rust | ||
180 | // BEFORE | ||
181 | enum Action { Move { distance: u32 }, Stop } | ||
182 | |||
183 | fn handle(action: Action) { | ||
184 | match action { | ||
185 | <|> | ||
186 | } | ||
187 | } | ||
188 | |||
189 | // AFTER | ||
190 | enum Action { Move { distance: u32 }, Stop } | ||
191 | |||
192 | fn handle(action: Action) { | ||
193 | match action { | ||
194 | Action::Move{ distance } => (), | ||
195 | Action::Stop => (), | ||
196 | } | ||
197 | } | ||
198 | ``` | ||
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 { | |||
118 | } | 118 | } |
119 | ``` | 119 | ``` |
120 | 120 | ||
121 | - Change Visibility | ||
122 | |||
123 | ```rust | ||
124 | // before: | ||
125 | <|>fn foo() {} | ||
126 | |||
127 | // after: | ||
128 | <|>pub(crate) fn foo() {} | ||
129 | |||
130 | // after: | ||
131 | <|>pub fn foo() {} | ||
132 | ``` | ||
133 | |||
134 | - Fill match arms | ||
135 | |||
136 | ```rust | ||
137 | // before: | ||
138 | enum A { | ||
139 | As, | ||
140 | Bs, | ||
141 | Cs(String), | ||
142 | Ds(String, String), | ||
143 | Es{x: usize, y: usize} | ||
144 | } | ||
145 | |||
146 | fn main() { | ||
147 | let a = A::As; | ||
148 | match a<|> {} | ||
149 | } | ||
150 | |||
151 | // after: | ||
152 | enum A { | ||
153 | As, | ||
154 | Bs, | ||
155 | Cs(String), | ||
156 | Ds(String, String), | ||
157 | Es{x: usize, y: usize} | ||
158 | } | ||
159 | |||
160 | fn main() { | ||
161 | let a = A::As; | ||
162 | match <|>a { | ||
163 | A::As => (), | ||
164 | A::Bs => (), | ||
165 | A::Cs(_) => (), | ||
166 | A::Ds(_, _) => (), | ||
167 | A::Es{x, y} => (), | ||
168 | } | ||
169 | } | ||
170 | ``` | ||
171 | |||
172 | - Fill struct fields | 121 | - Fill struct fields |
173 | 122 | ||
174 | ```rust | 123 | ```rust |