rust-lang / rust-lang/rustfmt

Allow a rest pattern before closing brace when destructuring

Open
#4,893 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request community driven P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Example for a struct:

let Self {
    x,
    y,
.. } = self;

match x {
    Variant::A {
        a,
        b,
    .. } => { /* snip */ }
    _ => todo!(),
}

Currently a .. is placed either on a separate line, or, in case of match and/or a short list of required fields, right after the trailing comma, all on the same line. I also think the above style may serve the best for the same purpose that a trailing commas are intended for. Please consider, thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the struct and match examples from the issue with rustfmt, then locate the existing formatting behavior for destructuring rest patterns. Done means rustfmt consistently permits and preserves the shown placement of .. before the closing brace without regressing other destructuring formats.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.