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};
7
7
8
8
use super :: * ;
9
9
10
+ /// If 6th bit set ascii is upper case.
11
+ const ASCII_CASE_MASK : u8 = 0b10_0000u8 ;
12
+
10
13
#[ lang = "char" ]
11
14
impl char {
12
15
/// The highest valid code point a `char` can have.
@@ -1090,8 +1093,7 @@ impl char {
1090
1093
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
1091
1094
#[ inline]
1092
1095
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 }
1095
1097
}
1096
1098
1097
1099
/// Makes a copy of the value in its ASCII lower case equivalent.
@@ -1119,8 +1121,7 @@ impl char {
1119
1121
#[ stable( feature = "ascii_methods_on_intrinsics" , since = "1.23.0" ) ]
1120
1122
#[ inline]
1121
1123
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 }
1124
1125
}
1125
1126
1126
1127
/// Checks that two values are an ASCII case-insensitive match.
You can’t perform that action at this time.
0 commit comments