diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-11 19:40:46 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-11 19:40:46 +0100 |
commit | fd06fe7b13045185ab4e630b0044aa9d8bbcdf8a (patch) | |
tree | 1481f3fb3e65902b36571ad403fabf5e5940aa56 /docs | |
parent | 1a1c09ed3e3a34c0a8750f98ece9ad85595395d2 (diff) | |
parent | d9089245fefdc4179c1d61839e78131c5e5a5a45 (diff) |
Merge #3925
3925: Implement assist "Reorder field names" r=matklad a=geoffreycopin
This PR implements the "Reorder record fields" assist as discussed in issue #3821 .
Adding a `RecordFieldPat` variant to the `Pat` enum seemed like the easiest way to handle the `RecordPat` children as a single sequence of elements, maybe there is a better way ?
Co-authored-by: Geoffrey Copin <[email protected]>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user/assists.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/user/assists.md b/docs/user/assists.md index cc42169d8..1d9510423 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -582,6 +582,21 @@ impl Walrus { | |||
582 | } | 582 | } |
583 | ``` | 583 | ``` |
584 | 584 | ||
585 | ## `reorder_fields` | ||
586 | |||
587 | Reorder the fields of record literals and record patterns in the same order as in | ||
588 | the definition. | ||
589 | |||
590 | ```rust | ||
591 | // BEFORE | ||
592 | struct Foo {foo: i32, bar: i32}; | ||
593 | const test: Foo = ┃Foo {bar: 0, foo: 1} | ||
594 | |||
595 | // AFTER | ||
596 | struct Foo {foo: i32, bar: i32}; | ||
597 | const test: Foo = Foo {foo: 1, bar: 0} | ||
598 | ``` | ||
599 | |||
585 | ## `replace_if_let_with_match` | 600 | ## `replace_if_let_with_match` |
586 | 601 | ||
587 | Replaces `if let` with an else branch with a `match` expression. | 602 | Replaces `if let` with an else branch with a `match` expression. |