File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -559,10 +559,9 @@ impl str {
559
559
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
560
560
#[ inline]
561
561
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
566
565
}
567
566
568
567
/// Returns a copy of this string where each character is mapped to its
@@ -592,10 +591,9 @@ impl str {
592
591
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
593
592
#[ inline]
594
593
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
599
597
}
600
598
}
601
599
You can’t perform that action at this time.
0 commit comments