Add single line if block support for single expression
Open
Nobody has claimed this yet.
C-feature-request
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
What did you expect?
if false { continue }
let Some(x) = opt else { return };
What did you get?
if false {
continue
}
let Some(x) = opt else { return };
cargo fmt puts let-else on a single line, and it could do the same to if blocks that have a single expression (i.e. return, break, or continue). That way there can be a consistent style for all guards.
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
Start by locating rustfmt's formatting logic for if blocks and the existing handling for let-else expressions. Run cargo fmt on the examples in the issue, then verify that if blocks containing only return, break, or continue stay on one line while other blocks retain their current formatting.
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
- Clearly specified
- Newbie friendliness
- 45/100