3 ms·
Because 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 mem
by LegionMammal978 3y ago
Because 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/