48 ms·
Why couldn’t the Rust compiler also assume that dissimilar types don’t alias?
by celeritascelery 3y ago
Why couldn’t the Rust compiler also assume that dissimilar types don’t alias?
- LegionMammal978 3y agoBecause existing unsafe code written in stable Rust depends on the ability to convert raw pointers and references from one type to another, as long as their memory layouts match. That's the whole premise of the bytemuck crate [0], and it's the basis for things like the &str-to-&[u8] or &[u8]-to-&str conversions in the standard library. [0] https://docs.rs/bytemuck/latest/bytemuck/ https://docs.rs/bytemuck/latest/bytemuck/