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/callbacks.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/callbacks.rs')
-rw-r--r-- | bindgen/callbacks.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bindgen/callbacks.rs b/bindgen/callbacks.rs index fb84c8c3..bebd6978 100644 --- a/bindgen/callbacks.rs +++ b/bindgen/callbacks.rs @@ -105,7 +105,15 @@ pub trait ParseCallbacks: fmt::Debug { /// /// If no additional attributes are wanted, this function should return an /// empty `Vec`. - fn add_derives(&self, _name: &str) -> Vec<String> { + fn add_derives(&self, _info: &DeriveInfo<'_>) -> Vec<String> { vec![] } } + +/// Relevant information about a type to which new derive attributes will be added using +/// [`ParseCallbacks::add_derives`]. +#[non_exhaustive] +pub struct DeriveInfo<'a> { + /// The name of the type. + pub name: &'a str, +} |