Skip to content

Use safe transmute by default #48

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

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

Conversation

konstin
Copy link
Member

@konstin konstin commented Mar 14, 2025

Using the zerocopy crate, we can port all header conversions from pointer cast to safe transmutes. After this change, the code in header.rs does not use unsafe anymore when the zerocopy feature is activated.

Since this adds a derive crate without feature addition as dependency, zerocopy is an optional (but on-by-default) dependency.

@konstin
Copy link
Member Author

konstin commented Mar 14, 2025

I did this as a learning exercise for safe transmutes. After this change, there are two unsafe remaining, both in Guard.

Base automatically changed from konsti/edition-2024 to main March 14, 2025 22:21
Using the zerocopy crate, we can port all header conversions from pointer cast to safe transmutes. After this change, the code in `header.rs` does not use `unsafe` anymore when the `zerocopy` feature is activated.

Since this adds a derive crate without feature addition as dependency, zerocopy is an optional (but on-by-default) dependency.
@konstin konstin force-pushed the konsti/safe-transmute branch from 2764be2 to 860ebb3 Compare March 17, 2025 09:00
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.

1 participant