rust-lang / rust-lang/rust-analyzer
Feature request: simplify match expression
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
When I'm refactoring and inlining stuff all over the place, I often end up with cases like this:
match Some(foo()) {
None => { do_none() }
Some(0) => { do_0() }
Some(1) => { do_1() }
_ => { do_wild() }
}
I would love an assist that keeps only the Some branches and simplifies this to
match foo() {
0 => { do_0() }
1 => { do_1() }
_ => { do_wild() }
}
It would also make sense for if lets and even plain ifs.
I realize this is unlikely to be actionable until match checking is librarified, but that's not too far in the future hopefully.
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 with the Rust match, if let, and if examples in the issue, then assess the stated prerequisite that match checking be librarified. Done means an assist can simplify the shown Some match while preserving the 0, 1, and wildcard branches, with the intended scope for if let and plain if clarified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100