News for hackers. Stuff that matters.
Re:Why introduce `std::launder` rather than have the compile... by pornel on Saturday January 22, 2022 @07:44AM (#30036194)
The exact same approach as C is doing is possible in Rust. There are pointer casts and mem::transmute(). It does require unsafe, since you must be aware of gotchas with alignment, padding, and uninitialized memory.

If you want to be fancy, there's https://lib.rs/rkyv deserialization framework that will auto-generate appropriate zero-copy code for you.

There's also serde (de)serialization framework and bincode format, which aren't exactly zero-copy, but are fast 1-copy.

There are no comments on this comment yet.