-
Notifications
You must be signed in to change notification settings - Fork 465
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
Improve the Interface
trait
#1738
Conversation
Note that parts of this trait are meant for public consumption. That's why some members were hidden. Notably, |
@kennykerr that sounds fine. I would argue for the newly added |
af440bf
to
ac88754
Compare
@kennykerr the latest nightly of clippy brought some new things to fix which I did, but it made the reviews stale. Can you re-review (only the last commit is new), and merge? |
Note: since this involves changes to generated code, it's easiest to review this commit by commit. The codegen was run in a separate commit from the other changes.
This improves the safety auditability of the
Interface
trait:Interface
trait. Even though this trait is not meant for public consumption, the docs can really help those reviewing the safety of generated code.as_raw
method to the trait which simply wrapsstd::mem::transmute_copy
.transmute_copy
is very powerful and easy to use wrong. Having a bespoke method for converting an interface to a raw pointer which is documented as such makes the code easier to read. We've also had several users ask for this type of functionality before.Interface::vtable
asunsafe
since this method is in fact safe.Finally, we use the
Interface::as_raw
method instead ofstd::mem::transmute_copy
in the generated code.cc @eholk