diff options
Diffstat (limited to 'docs/user/assists.md')
-rw-r--r-- | docs/user/assists.md | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/docs/user/assists.md b/docs/user/assists.md index 34a95696c..e4d08a7dc 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -38,6 +38,22 @@ fn main() { | |||
38 | } | 38 | } |
39 | ``` | 39 | ``` |
40 | 40 | ||
41 | ## `add_hash` | ||
42 | |||
43 | Adds a hash to a raw string literal. | ||
44 | |||
45 | ```rust | ||
46 | // BEFORE | ||
47 | fn main() { | ||
48 | r#"Hello,┃ World!"#; | ||
49 | } | ||
50 | |||
51 | // AFTER | ||
52 | fn main() { | ||
53 | r##"Hello, World!"##; | ||
54 | } | ||
55 | ``` | ||
56 | |||
41 | ## `add_impl` | 57 | ## `add_impl` |
42 | 58 | ||
43 | Adds a new inherent impl for a type. | 59 | Adds a new inherent impl for a type. |
@@ -266,6 +282,38 @@ fn main() { | |||
266 | } | 282 | } |
267 | ``` | 283 | ``` |
268 | 284 | ||
285 | ## `make_raw_string` | ||
286 | |||
287 | Adds `r#` to a plain string literal. | ||
288 | |||
289 | ```rust | ||
290 | // BEFORE | ||
291 | fn main() { | ||
292 | "Hello,┃ World!"; | ||
293 | } | ||
294 | |||
295 | // AFTER | ||
296 | fn main() { | ||
297 | r#"Hello, World!"#; | ||
298 | } | ||
299 | ``` | ||
300 | |||
301 | ## `make_usual_string` | ||
302 | |||
303 | Turns a raw string into a plain string. | ||
304 | |||
305 | ```rust | ||
306 | // BEFORE | ||
307 | fn main() { | ||
308 | r#"Hello,┃ "World!""#; | ||
309 | } | ||
310 | |||
311 | // AFTER | ||
312 | fn main() { | ||
313 | "Hello, \"World!\""; | ||
314 | } | ||
315 | ``` | ||
316 | |||
269 | ## `merge_match_arms` | 317 | ## `merge_match_arms` |
270 | 318 | ||
271 | Merges identical match arms. | 319 | Merges identical match arms. |
@@ -358,3 +406,74 @@ fn handle(action: Action) { | |||
358 | } | 406 | } |
359 | } | 407 | } |
360 | ``` | 408 | ``` |
409 | |||
410 | ## `remove_dbg` | ||
411 | |||
412 | Removes `dbg!()` macro call. | ||
413 | |||
414 | ```rust | ||
415 | // BEFORE | ||
416 | fn main() { | ||
417 | ┃dbg!(92); | ||
418 | } | ||
419 | |||
420 | // AFTER | ||
421 | fn main() { | ||
422 | 92; | ||
423 | } | ||
424 | ``` | ||
425 | |||
426 | ## `remove_hash` | ||
427 | |||
428 | Removes a hash from a raw string literal. | ||
429 | |||
430 | ```rust | ||
431 | // BEFORE | ||
432 | fn main() { | ||
433 | r#"Hello,┃ World!"#; | ||
434 | } | ||
435 | |||
436 | // AFTER | ||
437 | fn main() { | ||
438 | r"Hello, World!"; | ||
439 | } | ||
440 | ``` | ||
441 | |||
442 | ## `replace_if_let_with_match` | ||
443 | |||
444 | Replaces `if let` with an else branch with a `match` expression. | ||
445 | |||
446 | ```rust | ||
447 | // BEFORE | ||
448 | enum Action { Move { distance: u32 }, Stop } | ||
449 | |||
450 | fn handle(action: Action) { | ||
451 | ┃if let Action::Move { distance } = action { | ||
452 | foo(distance) | ||
453 | } else { | ||
454 | bar() | ||
455 | } | ||
456 | } | ||
457 | |||
458 | // AFTER | ||
459 | enum Action { Move { distance: u32 }, Stop } | ||
460 | |||
461 | fn handle(action: Action) { | ||
462 | match action { | ||
463 | Action::Move { distance } => foo(distance), | ||
464 | _ => bar(), | ||
465 | } | ||
466 | } | ||
467 | ``` | ||
468 | |||
469 | ## `split_import` | ||
470 | |||
471 | Wraps the tail of import into braces. | ||
472 | |||
473 | ```rust | ||
474 | // BEFORE | ||
475 | use std::┃collections::HashMap; | ||
476 | |||
477 | // AFTER | ||
478 | use std::{collections::HashMap}; | ||
479 | ``` | ||