Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add transmute_container! macro #1736

wants to merge 1 commit into from

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Sep 23, 2024

This is a draft implementation of #1735

Copy link
Collaborator

@jswrenn jswrenn left a 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!

Cargo.toml Show resolved Hide resolved
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))]
Copy link
Collaborator

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).

Copy link
Member Author

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?

Copy link
Collaborator

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.

Copy link
Member Author

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.

@joshlf joshlf force-pushed the container-transmute branch 4 times, most recently from 27dcf55 to d54acba Compare September 27, 2024 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants