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