From 192178f936f0057932e117183f774f0e2cce832c Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Mon, 11 Sep 2023 16:26:40 -0700 Subject: [PATCH] Guarantee `char` layout --- src/types/textual.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/textual.md b/src/types/textual.md index 41ed35ea1..fcbec0823 100644 --- a/src/types/textual.md +++ b/src/types/textual.md @@ -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::()]>(...)` is always sound -- but since