Skip to content

Allow specifying derive name #1301

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

Closed
spease opened this issue Apr 3, 2018 · 5 comments
Closed

Allow specifying derive name #1301

spease opened this issue Apr 3, 2018 · 5 comments

Comments

@spease
Copy link

spease commented Apr 3, 2018

There's probably some overlap with this and other issues, but rather than having a derive() function for each derive, I'd just either let somebody specify it (derive("PartialOrd")) or specify multiple ones somehow (derive("Clone,Copy")). This reduces the API size and increases functionality.

There are some special cases where derivations automatically trigger other derivations, I'd either just make derive() a straight specification of exactly what you want to appear (this might allow for other things besides just names down the road, if that ever gets supported). Or go ahead and parse the list and automatically derive those things.

@emilio
Copy link
Contributor

emilio commented Apr 3, 2018

The issue with this is that different derive(..) stuff have different requirements. Those requirements are encoded in src/ir/analysis/derive_*. Not sure how feasible would it be to make that logic work for generic derive, I guess someone would have to try.

@spease
Copy link
Author

spease commented Apr 9, 2018

I was suggesting hardcoding the the requirements for the default derives. Presumably user libraries are not going to replace them, or at least not commonly.

@pvdrz
Copy link
Contributor

pvdrz commented Feb 1, 2023

you can use the custom derive API for this nowadays

@pvdrz pvdrz closed this as completed Feb 1, 2023
@Plegeus
Copy link

Plegeus commented Jun 29, 2024

you can use the custom derive API for this nowadays

Dear Pvdrz,
Could you give me a pointer to this api?
I have been looking for this four an hour now, all I see is the specific function (derive_copy, derive_debug, etc.) on the Builder struct.
Thank you.

@pvdrz
Copy link
Contributor

pvdrz commented Jul 1, 2024

https://docs.rs/bindgen/latest/bindgen/callbacks/trait.ParseCallbacks.html#method.add_derives

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

No branches or pull requests

4 participants