Hacker News new | past | comments | ask | show | jobs | submit login

`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.




Thanks for clarifying that for me!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: