Merge pull request #1401 from joshlf/patch-2

Guarantee `char` layout
This commit is contained in:
Eric Huss 2023-10-30 19:07:58 +00:00 committed by GitHub
commit 8947db0c1e
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