rust-bindgen
rust-bindgen copied to clipboard
RFE: API for renaming struct fields
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
.