4 ms·
Not a Rust developer. How is transmute different than casting in C++?
by mempko 2y ago
Not a Rust developer. How is transmute different than casting in C++?
- steveklabnik 2y agoIn my understanding, transmute is reinterpret_cast.
- mtklein 2y agoLooks a little more like std::bit_cast? (Of course, there's a large overlap between the two.)
- steveklabnik 2y agoTIL about bit_cast. You may be correct, checking out its docs. The StackOverflow answer I just read comparing the two suggests bit_cast is a library function, transmute is an intrinsic. But transmute is const, and reinterpret_cast isn’t. So on some level it’s a mix of the two. Most important thing is that it’s closer to this kind of cast than a normal one.