Single expression match arm blocks on one line
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
i think there should be an option such that if a match arm is in a block but consists of a single expression, rustfmt keeps it on a single line. i.e.
match x {
0 => { foo(); }
1 => { bar(); }
_ => { baz(); }
}
which, by default, gets formatted to
match x {
0 => {
foo();
}
1 => {
bar();
}
_ => {
baz();
}
}
the reason for doing this being to throw away the result of foo(), bar(), and baz(), as if they returned different types, the match expression would cause a type error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named in the issue. Start by reproducing the two match-formatting examples and tracing rustfmt's match-arm formatting and option handling. Done means an option controls single-expression block arms on one line, with coverage for arms whose expressions return different types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100