News for hackers. Stuff that matters.
Re:Why introduce `std::launder` rather than have the compile... by roblabla on Saturday January 22, 2022 @07:38AM (#30036164)
In current Rust, you'd do it with an unsafe std::mem::transmute - possibly using a crate that wraps this call behind a safe interface that asserts that alignment and size are correct, and that your type doesn't have any padding, etc... See for instance the bytemuck crate.

In the future, rust might gain "Safe Transmutes", which would allow you to safely transmute from one type to another under some limited conditions. See https://github.com/rust-lang/lang-team/issues/21

There are no comments on this comment yet.