rust-lang / rust-lang/rust-analyzer
Replace field access with getter/setter
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I have a struct with a field that has been public but would now like to change it to be accessed via a getter. There's an assist to generate but could there be a way to also replace accesses to the field with the getter?
I guess it could be hard/impossible to know if the getter/getter_mut/setter should be used. But in my specific case the field is only ever read and I only wish to generate a read only getter.
Could this be implemented and/or is there a way to do this currently using some sort of find/replace?
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
The issue names no files or tests; start by locating the existing assist that generates getters and tracing the related field-access handling. Define the supported read-only case and verify it with focused assist tests; done means matching field reads are safely converted without changing mutable or ambiguous accesses.
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
- 35/100