Skip to content

Use safe transmute by default#48

Open
konstin wants to merge 1 commit intomainfrom
konsti/safe-transmute
Open

Use safe transmute by default#48
konstin wants to merge 1 commit intomainfrom
konsti/safe-transmute

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