Skip to content

Commit ea1110b

Browse files
joshlfRalfJung
andauthored
Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
1 parent 746a359 commit ea1110b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/types/pointer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Despite pointers and references being similar to `usize`s in the machine code em
5656
the semantics of transmuting a reference or pointer type to a non-pointer type is currently undecided.
5757
Thus, it may not be valid to transmute a pointer or reference type, `P`, to a `[u8; size_of::<P>()]`.
5858

59+
For thin raw pointers (i.e., for `<T as Pointee>::Metadata == ()` and `P = *const T` or `P = *mut T`),
60+
the inverse direction (transmuting from an integer or array of integers to `P`) is always valid.
61+
However, the pointer produced via such a transmutation may not be dereferenced (not even if `T` has size zero).
62+
5963
[`core::ptr::addr_of!`]: ../../core/ptr/macro.addr_of.html
6064
[`core::ptr::addr_of_mut!`]: ../../core/ptr/macro.addr_of_mut.html
6165
[Interior mutability]: ../interior-mutability.md

0 commit comments

Comments
 (0)