diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2022-04-07 07:52:07 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-07 07:52:07 +0300 |
| commit | b399e7ea7c99a24f43e9562b0fb5223833a8bb50 (patch) | |
| tree | 46533543dafddb2010de9b217f175cda68726216 | |
| parent | 2310da432ca1c3e87f1d17e069f2336f2d4939e5 (diff) | |
| download | rust-b399e7ea7c99a24f43e9562b0fb5223833a8bb50.tar.gz rust-b399e7ea7c99a24f43e9562b0fb5223833a8bb50.zip | |
Correct safety reasoning in `str::make_ascii_{lower,upper}case()`
| -rw-r--r-- | library/core/src/str/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 6bfa6a5e015..82208c4deaa 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -2407,7 +2407,7 @@ impl str { #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[inline] pub fn make_ascii_uppercase(&mut self) { - // SAFETY: safe because we transmute two types with the same layout. + // SAFETY: changing ASCII letters only does not invalidate UTF-8. let me = unsafe { self.as_bytes_mut() }; me.make_ascii_uppercase() } @@ -2434,7 +2434,7 @@ impl str { #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[inline] pub fn make_ascii_lowercase(&mut self) { - // SAFETY: safe because we transmute two types with the same layout. + // SAFETY: changing ASCII letters only does not invalidate UTF-8. let me = unsafe { self.as_bytes_mut() }; me.make_ascii_lowercase() } |
