Skip to content

Commit 41b7e5f

Browse files
committed
Auto merge of rust-lang#132500 - RalfJung:char-is-whitespace-const, r=jhpratt
make char::is_whitespace unstably const I am adding this to the existing rust-lang#132241 feature gate, since `is_digit` and `is_whitespace` seem similar enough that one can group them together.
2 parents f4e9fe4 + 11dc6c3 commit 41b7e5f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

core/src/char/methods.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl char {
320320
/// '1'.is_digit(37);
321321
/// ```
322322
#[stable(feature = "rust1", since = "1.0.0")]
323-
#[rustc_const_unstable(feature = "const_char_is_digit", issue = "132241")]
323+
#[rustc_const_unstable(feature = "const_char_classify", issue = "132241")]
324324
#[inline]
325325
pub const fn is_digit(self, radix: u32) -> bool {
326326
self.to_digit(radix).is_some()
@@ -856,8 +856,9 @@ impl char {
856856
/// ```
857857
#[must_use]
858858
#[stable(feature = "rust1", since = "1.0.0")]
859+
#[rustc_const_unstable(feature = "const_char_classify", issue = "132241")]
859860
#[inline]
860-
pub fn is_whitespace(self) -> bool {
861+
pub const fn is_whitespace(self) -> bool {
861862
match self {
862863
' ' | '\x09'..='\x0d' => true,
863864
c => c > '\x7f' && unicode::White_Space(c),

core/src/unicode/unicode_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ pub mod white_space {
572572
0, 0, 0, 0, 0, 0, 0, 0, 0,
573573
];
574574
#[inline]
575-
pub fn lookup(c: char) -> bool {
575+
pub const fn lookup(c: char) -> bool {
576576
match c as u32 >> 8 {
577577
0 => WHITESPACE_MAP[c as usize & 0xff] & 1 != 0,
578578
22 => c as u32 == 0x1680,

0 commit comments

Comments
 (0)