Guarantee `char` layout

This commit is contained in:
Joshua Liebow-Feeser 2023-09-11 16:26:40 -07:00 committed by GitHub
parent ee7c676fd6
commit 192178f936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -17,7 +17,9 @@ is valid UTF-8. Calling a `str` method with a non-UTF-8 buffer can cause
Since `str` is a [dynamically sized type], it can only be instantiated through a
pointer type, such as `&str`.
## Bit validity
## Layout and bit validity
`char` is guaranteed to have the same size and alignment as `u32` on all platforms.
Every byte of a `char` is guaranteed to be initialized (in other words,
`transmute::<char, [u8; size_of::<char>()]>(...)` is always sound -- but since