Skip to content

Provide zerocopy trait implementations behind feature flag #3317

Closed as not planned
@joshlf

Description

@joshlf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions