File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ use crate::unicode::{self, conversions};
77
88use super :: * ;
99
10+ /// If 6th bit set ascii is upper case.
11+ const ASCII_CASE_MASK : u8 = 0b10_0000u8 ;
12+
1013#[ lang = "char" ]
1114impl char {
1215 /// The highest valid code point a `char` can have.
@@ -1090,8 +1093,7 @@ impl char {
10901093 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
10911094 #[ inline]
10921095 pub fn to_ascii_uppercase ( & self ) -> char {
1093- // 6th bit dictates ascii case.
1094- if self . is_ascii_lowercase ( ) { ( ( * self as u8 ) & !0b10_0000u8 ) as char } else { * self }
1096+ if self . is_ascii_lowercase ( ) { ( ( * self as u8 ) & !ASCII_CASE_MASK ) as char } else { * self }
10951097 }
10961098
10971099 /// Makes a copy of the value in its ASCII lower case equivalent.
@@ -1119,8 +1121,7 @@ impl char {
11191121 #[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
11201122 #[ inline]
11211123 pub fn to_ascii_lowercase ( & self ) -> char {
1122- // 6th bit dictates ascii case.
1123- if self . is_ascii_uppercase ( ) { ( ( * self as u8 ) | 0b10_0000u8 ) as char } else { * self }
1124+ if self . is_ascii_uppercase ( ) { ( ( * self as u8 ) | ASCII_CASE_MASK ) as char } else { * self }
11241125 }
11251126
11261127 /// Checks that two values are an ASCII case-insensitive match.
You can’t perform that action at this time.
0 commit comments