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

Provide zerocopy trait implementations behind feature flag #3317

Open
joshlf opened this issue Aug 9, 2023 · 0 comments
Open

Provide zerocopy trait implementations behind feature flag #3317

joshlf opened this issue Aug 9, 2023 · 0 comments
Labels
C-API-request Category: API request

Comments

@joshlf
Copy link
Contributor

joshlf commented Aug 9, 2023

A common use of unsafe code is to access or modify the bytes of libc types (e.g. by transmuting them; here's an example). Many libc types could implement the zerocopy traits (FromBytes, AsBytes, and Unaligned) by using a custom derive, so this would just be a matter of adding #[cfg_attr(feature = "zerocopy", derive(FromBytes, AsBytes, Unaligned))] to the types which support it. This would allow all of those uses to be safe.

If this is something that the maintainers would be open to, I'd be happy to put up a PR.

@joshlf joshlf added the C-API-request Category: API request label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-API-request Category: API request
Projects
None yet
Development

No branches or pull requests

1 participant