From e9f628e1098c03a13e9b40e3d6c9fe2563d91239 Mon Sep 17 00:00:00 2001 From: Kashiwa Date: Fri, 24 Nov 2023 17:18:44 +0800 Subject: [PATCH 1/2] Update comment for consistent context logic. --- library/core/src/num/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 2a0b31404f035..e98415a40be39 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -549,7 +549,7 @@ impl u8 { #[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.52.0")] #[inline] pub const fn to_ascii_uppercase(&self) -> u8 { - // Toggle the fifth bit if this is a lowercase letter + // Toggle the 6th bit if this is a lowercase letter *self ^ ((self.is_ascii_lowercase() as u8) * ASCII_CASE_MASK) } @@ -574,7 +574,7 @@ impl u8 { #[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.52.0")] #[inline] pub const fn to_ascii_lowercase(&self) -> u8 { - // Set the fifth bit if this is an uppercase letter + // Set the 6th bit if this is an uppercase letter *self | (self.is_ascii_uppercase() as u8 * ASCII_CASE_MASK) } From 1928d82385824810d2aa9b93a3459cf04dbb393a Mon Sep 17 00:00:00 2001 From: Kashiwa Date: Fri, 24 Nov 2023 17:23:49 +0800 Subject: [PATCH 2/2] correct grammar --- library/core/src/num/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index e98415a40be39..695e87aaabf8a 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -474,7 +474,7 @@ impl isize { } } -/// If 6th bit is set ascii is lower case. +/// If the 6th bit is set ascii is lower case. const ASCII_CASE_MASK: u8 = 0b0010_0000; impl u8 {