NLnetLabs / domain

A DNS library for Rust.
https://nlnetlabs.nl/projects/domain/about/
BSD 3-Clause "New" or "Revised" License
332 stars 56 forks source link

Refactor pointer casts to transmutes and annotate with repr(transparent) #324

Closed tertsdiepraam closed 1 month ago

tertsdiepraam commented 1 month ago

We're doing many pointer casts, which Rust has a more convenient function for: std::mem::transmute, this reduces the syntactical overhead and is easier to understand for linters (such as MIRI and clippy).

Additionally, all these pointer casts were theoretically unsound, because #[repr(transparent)] was missing. I added safety comments as well referencing that attribute.

We should probably be running MIRI to really ensure that everything we're doing is safe.