Skip to content

Commit f30c51a

Browse files
committed
Pulling out constant.
1 parent f165f49 commit f30c51a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

library/core/src/char/methods.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ use crate::unicode::{self, conversions};
77

88
use super::*;
99

10+
/// If 6th bit set ascii is upper case.
11+
const ASCII_CASE_MASK: u8 = 0b10_0000u8;
12+
1013
#[lang = "char"]
1114
impl 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.

0 commit comments

Comments
 (0)