Skip to content

Commit 9704911

Browse files
authored
Use matches! for core::char methods
1 parent d890e64 commit 9704911

File tree

1 file changed

+10
-40
lines changed

1 file changed

+10
-40
lines changed

library/core/src/char/methods.rs

+10-40
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,7 @@ impl char {
12291229
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
12301230
#[inline]
12311231
pub const fn is_ascii_alphabetic(&self) -> bool {
1232-
match *self {
1233-
'A'..='Z' | 'a'..='z' => true,
1234-
_ => false,
1235-
}
1232+
matches!(*self, 'A'..='Z' | 'a'..='z')
12361233
}
12371234

12381235
/// Checks if the value is an ASCII uppercase character:
@@ -1265,10 +1262,7 @@ impl char {
12651262
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
12661263
#[inline]
12671264
pub const fn is_ascii_uppercase(&self) -> bool {
1268-
match *self {
1269-
'A'..='Z' => true,
1270-
_ => false,
1271-
}
1265+
matches!(*self, 'A'..='Z')
12721266
}
12731267

12741268
/// Checks if the value is an ASCII lowercase character:
@@ -1301,10 +1295,7 @@ impl char {
13011295
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
13021296
#[inline]
13031297
pub const fn is_ascii_lowercase(&self) -> bool {
1304-
match *self {
1305-
'a'..='z' => true,
1306-
_ => false,
1307-
}
1298+
matches!(*self, 'a'..='z')
13081299
}
13091300

13101301
/// Checks if the value is an ASCII alphanumeric character:
@@ -1340,10 +1331,7 @@ impl char {
13401331
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
13411332
#[inline]
13421333
pub const fn is_ascii_alphanumeric(&self) -> bool {
1343-
match *self {
1344-
'0'..='9' | 'A'..='Z' | 'a'..='z' => true,
1345-
_ => false,
1346-
}
1334+
matches!(*self, '0'..='9' | 'A'..='Z' | 'a'..='z')
13471335
}
13481336

13491337
/// Checks if the value is an ASCII decimal digit:
@@ -1376,10 +1364,7 @@ impl char {
13761364
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
13771365
#[inline]
13781366
pub const fn is_ascii_digit(&self) -> bool {
1379-
match *self {
1380-
'0'..='9' => true,
1381-
_ => false,
1382-
}
1367+
matches!(*self, '0'..='9')
13831368
}
13841369

13851370
/// Checks if the value is an ASCII hexadecimal digit:
@@ -1415,10 +1400,7 @@ impl char {
14151400
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
14161401
#[inline]
14171402
pub const fn is_ascii_hexdigit(&self) -> bool {
1418-
match *self {
1419-
'0'..='9' | 'A'..='F' | 'a'..='f' => true,
1420-
_ => false,
1421-
}
1403+
matches!(*self, '0'..='9' | 'A'..='F' | 'a'..='f')
14221404
}
14231405

14241406
/// Checks if the value is an ASCII punctuation character:
@@ -1455,10 +1437,7 @@ impl char {
14551437
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
14561438
#[inline]
14571439
pub const fn is_ascii_punctuation(&self) -> bool {
1458-
match *self {
1459-
'!'..='/' | ':'..='@' | '['..='`' | '{'..='~' => true,
1460-
_ => false,
1461-
}
1440+
matches!(*self, '!'..='/' | ':'..='@' | '['..='`' | '{'..='~')
14621441
}
14631442

14641443
/// Checks if the value is an ASCII graphic character:
@@ -1491,10 +1470,7 @@ impl char {
14911470
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
14921471
#[inline]
14931472
pub const fn is_ascii_graphic(&self) -> bool {
1494-
match *self {
1495-
'!'..='~' => true,
1496-
_ => false,
1497-
}
1473+
matches!(*self, '!'..='~')
14981474
}
14991475

15001476
/// Checks if the value is an ASCII whitespace character:
@@ -1544,10 +1520,7 @@ impl char {
15441520
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
15451521
#[inline]
15461522
pub const fn is_ascii_whitespace(&self) -> bool {
1547-
match *self {
1548-
'\t' | '\n' | '\x0C' | '\r' | ' ' => true,
1549-
_ => false,
1550-
}
1523+
matches!(*self, '\t' | '\n' | '\x0C' | '\r' | ' ')
15511524
}
15521525

15531526
/// Checks if the value is an ASCII control character:
@@ -1582,10 +1555,7 @@ impl char {
15821555
#[rustc_const_stable(feature = "const_ascii_ctype_on_intrinsics", since = "1.47.0")]
15831556
#[inline]
15841557
pub const fn is_ascii_control(&self) -> bool {
1585-
match *self {
1586-
'\0'..='\x1F' | '\x7F' => true,
1587-
_ => false,
1588-
}
1558+
matches!(*self, '\0'..='\x1F' | '\x7F')
15891559
}
15901560
}
15911561

0 commit comments

Comments
 (0)