rust-lang / rust-lang/rust-bindgen
RFE: API for renaming struct fields
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Background
ParseCallbacks::enum_variant_name is already useful for renaming enum variants. I'm using it to ensure that generated bindings fit Rust conventions. However, I'd like to also rename struct fields, and there doesn't seem to be a callback for that.
Proposal
Add fn struct_field_name to ParseCallbacks with the following signature:
fn struct_field_name(
&self,
struct_name: Option<&str>,
original_field_name: &str,
) -> Option<String>
This works in a similar manner to ParseCallbacks::enum_variant_name; if the user chooses to return None, the name isn't changed, but if the user chooses to return Some(string), then the field is renamed to string.
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
Locate ParseCallbacks and read the existing enum_variant_name callback and its implementation path first. Add the proposed struct_field_name entry point with matching None/Some behavior, then verify that generated struct fields use the returned name without changing the default.
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
- 38/100