diff options
author | Christian Poveda Ruiz <31802960+pvdrz@users.noreply.github.com> | 2022-11-21 10:38:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-21 10:38:42 -0500 |
commit | 34f0bacb7eb72413c9c27684cb01a205ee43037e (patch) | |
tree | 932004018c2777d40d2f81e52b87f31b0601d8dc /bindgen/codegen/mod.rs | |
parent | 8fe230830fa56e94efcaaa6833d536eec894a71e (diff) |
Introduce `DeriveInfo` (#2355)
This PR introduces a new non-exhaustive `struct` called `DeriveInfo` to be used as the sole argument of `ParseCallbacks::add_derives` with the purpose of being able to extend the information passed to this method in a backwards-compatible manner, meaning that adding new fields to `DeriveInfo` won't be a breaking change when releasing a new version.
Diffstat (limited to 'bindgen/codegen/mod.rs')
-rw-r--r-- | bindgen/codegen/mod.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index c7ac59db..e758963a 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -2114,9 +2114,11 @@ impl CodeGenerator for CompInfo { // The custom derives callback may return a list of derive attributes; // add them to the end of the list. - let custom_derives = ctx - .options() - .all_callbacks(|cb| cb.add_derives(&canonical_name)); + let custom_derives = ctx.options().all_callbacks(|cb| { + cb.add_derives(&crate::callbacks::DeriveInfo { + name: &canonical_name, + }) + }); // In most cases this will be a no-op, since custom_derives will be empty. derives.extend(custom_derives.iter().map(|s| s.as_str())); @@ -3168,8 +3170,9 @@ impl CodeGenerator for Enum { // The custom derives callback may return a list of derive attributes; // add them to the end of the list. - let custom_derives = - ctx.options().all_callbacks(|cb| cb.add_derives(&name)); + let custom_derives = ctx.options().all_callbacks(|cb| { + cb.add_derives(&crate::callbacks::DeriveInfo { name: &name }) + }); // In most cases this will be a no-op, since custom_derives will be empty. derives.extend(custom_derives.iter().map(|s| s.as_str())); |