rust-lang / rust-lang/rust-analyzer
"convert anonymous to named function" (and the other way around)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Often when working with transformation pipelines I'll start with inline anonymous functions, then after a while if the block grows large (and doesn't close over anything) I'll usually want to "promote" it to a function or method.
Currently this can be a bit fiddly depending on the way the anonymous function is defined e.g. if the parameter is a pattern rather than a single object, "extract into function" will take the "exploded" parameters which is not the point, so this can optionally require first converting back to a single object (#11113), then extracting the body of the anonymous function into a named function (via "extract into function"), then "unwrapping" the named function by removing the leftover bits from the anonymous one and the actual call.
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 existing "extract into function" refactoring and the related conversion described in issue #11113. Trace how anonymous functions with pattern parameters are handled, then define completion as supporting conversion between anonymous and named functions in both directions without exploded parameters or leftover wrapper code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100