@@ -56,23 +56,24 @@ Most primitives are generally aligned to their size, although this is
5656platform-specific behavior. In particular, on x86 u64 and f64 are only
5757aligned to 32 bits.
5858
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, for every primitive numeric
62- type, ` T ` , ` transmute::<[u8; size_of::<T>()], T>(...) ` is always sound). For the
63- primitive numeric types and also for ` bool ` and ` char ` , every byte is guaranteed to be
64- initialized (in other words, for every such type, ` T ` ,
59+ For every primitive numeric type (` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` ,
60+ ` i64 ` , ` u128 ` , ` i128 ` , ` usize ` , ` isize ` , ` f32 ` , and ` f64 ` ), ` T ` , the bit validity
61+ of ` T ` is equivalent to the bit validity of ` [u8; size_of::<T>()] ` . ` u8 ` has 256
62+ valid representations (namely, every 8-bit sequence). An uninitialized byte is not
63+ a valid u8. A byte at any offset in a reference or pointer type may not be a valid
64+ u8 (the semantics of transmuting a reference or pointer to a non-pointer type is
65+ currently undecided).
66+
67+ For the primitive numeric types and also for ` bool ` and ` char ` , every byte is
68+ guaranteed to be initialized (in other words, for every such type, ` T ` ,
6569` transmute::<T, [u8; size_of::<T>()]>(...) ` is always sound).
6670
6771## Pointers and References Layout
6872
6973Pointers and references have the same layout. Mutability of the pointer or
7074reference does not change the layout.
7175
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).
76+ Pointers to sized types have the same size and alignment as ` usize ` .
7677
7778Pointers to unsized types are sized. The size and alignment is guaranteed to be
7879at least equal to the size and alignment of a pointer.
0 commit comments