File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -993,9 +993,13 @@ extern "rust-intrinsic" {
993993 ///
994994 /// Note that using `transmute` to turn a pointer to a `usize` is (as noted above) [undefined
995995 /// behavior][ub] in `const` contexts. Also outside of consts, this operation might not behave
996- /// as expected -- this is touching on many unspecified aspects of the Rust memory model. To
997- /// make sure your code is well-defined, the conversion of pointers to integers and back should
998- /// always be done explicitly via casts.
996+ /// as expected -- this is touching on many unspecified aspects of the Rust memory model.
997+ /// Depending on what the code is doing, the following alternatives are preferrable to
998+ /// pointer-to-integer transmutation:
999+ /// - If the code just wants to store data of arbitrary type in some buffer and needs to pick a
1000+ /// type for that buffer, it can use [`MaybeUninit`][mem::MaybeUninit].
1001+ /// - If the code actually wants to work on the address the pointer points to, it can use `as`
1002+ /// casts or [`ptr.addr()`][pointer::addr].
9991003 ///
10001004 /// Turning a `*mut T` into an `&mut T`:
10011005 ///
You can’t perform that action at this time.
0 commit comments