Closed arielb1 closed 5 years ago
This issue is fixed, see the referenced issue.
It turns out indeed that transmute_copy
uses read_unaligned
. I had no idea. That might be worth calling out in its documentation?
Note that the reference still needs to be T
-aligned, as all references do. But it does not have to be U
-aligned.
It was changed in rust-lang/rust#55052.
std::mem::transmute_copy
should work on unaligned pointers, unlike dereferences andptr::read
.