Hacker News new | ask | show | jobs
by p4lindromica 2353 days ago
`mem::transmute` is roughly equivalent to a `reinterpret_cast` in C++. It treats the bits of a u8 as an i8.

In the Rust definition of safety (mutable xor shared, no data races, memory safety, etc), treating the bits of a u8 as an i8 is safe and can be done with an `as` cast.

1 comments

Thanks for clarifying that for me!