-
Notifications
You must be signed in to change notification settings - Fork 105
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 transmute_container! macro #1736
base: main
Are you sure you want to change the base?
Conversation
f555762
to
713dbed
Compare
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.
I like the general approach!
src/lib.rs
Outdated
@@ -303,6 +303,7 @@ | |||
__ZEROCOPY_INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS, | |||
feature(layout_for_ptr, strict_provenance, coverage_attribute) | |||
)] | |||
#![cfg_attr(feature = "unstable-transmute-vec", feature(vec_into_raw_parts))] |
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.
We should attempt to move the trait impl for Vec
into the macro, so that feature(vec_into_raw_parts)
is something our customers write instead of us. This makes it harder for customers to accidentally and unkowingly depend on a nightly feature (e.g., because another dependency enabled this cargo feature).
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.
Any ideas for how to do that given that the macro delegates to a trait impl and doesn't have access to the name of the container type being used?
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.
Ugly but bear with me: Move the trait and impl to inside the macro.
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.
Discussed offline. Going to just remove Vec
support for now.
27dcf55
to
d54acba
Compare
d54acba
to
c51c96a
Compare
This is a draft implementation of #1735