Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: API for renaming struct fields #2788

Open
jgcodes2020 opened this issue Mar 24, 2024 · 1 comment
Open

RFE: API for renaming struct fields #2788

jgcodes2020 opened this issue Mar 24, 2024 · 1 comment

Comments

@jgcodes2020
Copy link

jgcodes2020 commented Mar 24, 2024

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.

@pvdrz
Copy link
Contributor

pvdrz commented Mar 26, 2024

🤔 I wonder if having a single callback for both variants and structs would be a reasonable alternative or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants