-
Notifications
You must be signed in to change notification settings - Fork 696
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
add custom derives callback #2059
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good but needs a test. You can add one to e.g. bindgen-integration perhaps?
This callback allows us to specify arbitrary derive attributes for each named struct. This is useful for adding things that can't easily be implemented separately, such as `serde::Deserialize` or `zerocopy::FromBytes`.
57fb272
to
3f0a0db
Compare
This test derives PartialEq for the Test struct, and then attempts to use that by calling assert_ne! on two Test instances. If the derive callback doesn't work, no PartialEq will be present and the test will fail to compile.
I added a test to bindgen-integration, and verified that the test fails if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Is there anything I can do to help drive this change forward? |
No, sorry, I've been just on vacation most of June, will merge+release asap :) |
I'm happy to hear that. If there is any follow-up work needed, I'm happy to help contribute. |
Is there a way of adding a custom derive when using the CLI tool? |
@a-cristi Unfortunately, no. I couldn't imagine how the CLI would work, and I wasn't sure whether it would be useful, so I didn't even try. My opinion doesn't matter much (I'm not a regular contributor to this crate), so feel free to open a new issue to discuss the benefits of adding CLI support. |
I was thinking that it could work like |
This callback allows us to specify arbitrary derive attributes for each named struct. This is useful for adding things that can't easily be implemented separately, such as
serde::Deserialize
orzerocopy::FromBytes
.This addresses the easiest cases of #1089.
There aren't any tests yet-- I'm not sure what the best way would be to test this, since it can't be reduced to a command line.