You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We guarantee various things about the layout of pointers and
references, but we'd made no guarantees of equivalence between two
pointers to distinct unsized types that differ in the unsized tail.
Let's make some useful guarantees about this.
Copy file name to clipboardExpand all lines: src/type-layout.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,40 @@ Pointers to unsized types are sized. The size and alignment of a pointer to an u
69
69
> [!NOTE]
70
70
> Though you should not rely on this, all pointers to <abbrtitle="Dynamically Sized Types">DSTs</abbr> are currently twice the size of the size of `usize` and have the same alignment.
71
71
72
+
r[layout.pointer.parametric]
73
+
The raw pointer types `*const T` and `*const U` have the same layout, as do `*mut T` and `*mut U`, the shared references `&T` and `&U`, and the mutable references `&mut T` and `&mut U`, in each of the following cases:
74
+
75
+
-`T` and `U` are both sized types.
76
+
-`T` and `U` both have a [slice] or [`str`] as their [unsized tail].
77
+
-`T` and `U` both have a [trait object] as their unsized tail.
0 commit comments