mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Correct safety reasoning in str::make_ascii_{lower,upper}case()
This commit is contained in:
parent
2310da432c
commit
b399e7ea7c
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user