How to use (unsafe) aliasing?
问题 Rust has strict aliasing rules. But can I work around them if "I know what I'm doing"? I'm trying to convert to Rust a C function that performs a complicated operation by reading from input buffer and writing to a destination buffer, but it has a clever optimization that allows the input and output buffer to be the same: foo(src, dst); // result is written to dst foo(buf, buf); // legal in C, does the operation in-place For the sake of the question let's say it's something like: void inplace