File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -559,10 +559,9 @@ impl str {
559559 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
560560 #[ inline]
561561 pub fn to_ascii_uppercase ( & self ) -> String {
562- let mut bytes = self . as_bytes ( ) . to_vec ( ) ;
563- bytes. make_ascii_uppercase ( ) ;
564- // make_ascii_uppercase() preserves the UTF-8 invariant.
565- unsafe { String :: from_utf8_unchecked ( bytes) }
562+ let mut s = self . to_owned ( ) ;
563+ s. make_ascii_uppercase ( ) ;
564+ s
566565 }
567566
568567 /// Returns a copy of this string where each character is mapped to its
@@ -592,10 +591,9 @@ impl str {
592591 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
593592 #[ inline]
594593 pub fn to_ascii_lowercase ( & self ) -> String {
595- let mut bytes = self . as_bytes ( ) . to_vec ( ) ;
596- bytes. make_ascii_lowercase ( ) ;
597- // make_ascii_lowercase() preserves the UTF-8 invariant.
598- unsafe { String :: from_utf8_unchecked ( bytes) }
594+ let mut s = self . to_owned ( ) ;
595+ s. make_ascii_lowercase ( ) ;
596+ s
599597 }
600598}
601599
You can’t perform that action at this time.
0 commit comments