Correct safety reasoning in str::make_ascii_{lower,upper}case()
This commit is contained in:
parent
2310da432c
commit
b399e7ea7c
1 changed files with 2 additions and 2 deletions
|
@ -2407,7 +2407,7 @@ impl str {
|
||||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn make_ascii_uppercase(&mut self) {
|
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() };
|
let me = unsafe { self.as_bytes_mut() };
|
||||||
me.make_ascii_uppercase()
|
me.make_ascii_uppercase()
|
||||||
}
|
}
|
||||||
|
@ -2434,7 +2434,7 @@ impl str {
|
||||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn make_ascii_lowercase(&mut self) {
|
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() };
|
let me = unsafe { self.as_bytes_mut() };
|
||||||
me.make_ascii_lowercase()
|
me.make_ascii_lowercase()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue