Strict aliasing in Rust?
My understanding is that the following code has undefined behaviour in C++ due to something called "strict aliasing rule". #include <cstdint> enum Foo : int16_t {}; void test(Foo& foo) { reinterpret_cast<int16_t&>(foo) = 42; } In particular, a C++ compiler may omit the assignment altogether because it is allowed to assume that the int16_t& returned by the reinterpret_cast doesn't point to the same memory as foo (of type Foo& ) because their types are different. My question is, does Rust have something akin to the C++ "strict aliasing rule"? In other words, does the following, equivalent Rust