diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 5809ed1f33b07..3519f21fd95b8 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -1275,7 +1275,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_alphabetic(&self) -> bool { - matches!(*self, 'A'..='Z' | 'a'..='z') + (*self as u32 | 0b10_0000).wrapping_sub('a' as u32) < 26 } /// Checks if the value is an ASCII uppercase character: @@ -1380,7 +1380,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_alphanumeric(&self) -> bool { - matches!(*self, '0'..='9' | 'A'..='Z' | 'a'..='z') + self.is_ascii_digit() || self.is_ascii_alphabetic() } /// Checks if the value is an ASCII decimal digit: @@ -1451,7 +1451,7 @@ impl char { #[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")] #[inline] pub const fn is_ascii_hexdigit(&self) -> bool { - matches!(*self, '0'..='9' | 'A'..='F' | 'a'..='f') + self.is_ascii_digit() || (*self as u32 | 0b10_0000).wrapping_sub('a' as u32) < 6 } /// Checks if the value is an ASCII punctuation character: