@@ -56,12 +56,23 @@ Most primitives are generally aligned to their size, although this is
56
56
platform-specific behavior. In particular, on x86 u64 and f64 are only
57
57
aligned to 32 bits.
58
58
59
+ For the primitive numeric types (` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` ,
60
+ ` i64 ` , ` u128 ` , ` i128 ` , ` usize ` , ` isize ` , ` f32 ` , and ` f64 ` ), every bit pattern
61
+ represents a valid instance of the type (in other words,
62
+ ` transmute::<[u8; size_of::<T>()], T>(...) ` is always sound). For the primitive
63
+ numeric types and also for ` bool ` and ` char ` , every byte is guaranteed to be
64
+ initialized (in other words, `transmute::<T, [ u8; size_of::<T >()] >(...) is always
65
+ sound).
66
+
59
67
## Pointers and References Layout
60
68
61
69
Pointers and references have the same layout. Mutability of the pointer or
62
70
reference does not change the layout.
63
71
64
- Pointers to sized types have the same size and alignment as ` usize ` .
72
+ Pointers to sized types have the same size and alignment as ` usize ` . Every
73
+ byte of a pointer to a sized type and of a reference to a sized type is
74
+ initialized (in other words, for such a pointer or reference type, ` P ` ,
75
+ ` transmute::<P, [u8; size_of::<P>()]>(...) ` is always sound).
65
76
66
77
Pointers to unsized types are sized. The size and alignment is guaranteed to be
67
78
at least equal to the size and alignment of a pointer.
0 commit comments