@@ -1075,7 +1075,10 @@ impl char {
1075
1075
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1076
1076
#[ inline]
1077
1077
pub const fn is_ascii_alphabetic ( & self ) -> bool {
1078
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_alphabetic ( )
1078
+ match * self {
1079
+ 'A' ..='Z' | 'a' ..='z' => true ,
1080
+ _ => false ,
1081
+ }
1079
1082
}
1080
1083
1081
1084
/// Checks if the value is an ASCII uppercase character:
@@ -1108,7 +1111,10 @@ impl char {
1108
1111
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1109
1112
#[ inline]
1110
1113
pub const fn is_ascii_uppercase ( & self ) -> bool {
1111
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_uppercase ( )
1114
+ match * self {
1115
+ 'A' ..='Z' => true ,
1116
+ _ => false ,
1117
+ }
1112
1118
}
1113
1119
1114
1120
/// Checks if the value is an ASCII lowercase character:
@@ -1141,7 +1147,10 @@ impl char {
1141
1147
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1142
1148
#[ inline]
1143
1149
pub const fn is_ascii_lowercase ( & self ) -> bool {
1144
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_lowercase ( )
1150
+ match * self {
1151
+ 'a' ..='z' => true ,
1152
+ _ => false ,
1153
+ }
1145
1154
}
1146
1155
1147
1156
/// Checks if the value is an ASCII alphanumeric character:
@@ -1177,7 +1186,10 @@ impl char {
1177
1186
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1178
1187
#[ inline]
1179
1188
pub const fn is_ascii_alphanumeric ( & self ) -> bool {
1180
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_alphanumeric ( )
1189
+ match * self {
1190
+ '0' ..='9' | 'A' ..='Z' | 'a' ..='z' => true ,
1191
+ _ => false ,
1192
+ }
1181
1193
}
1182
1194
1183
1195
/// Checks if the value is an ASCII decimal digit:
@@ -1210,7 +1222,10 @@ impl char {
1210
1222
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1211
1223
#[ inline]
1212
1224
pub const fn is_ascii_digit ( & self ) -> bool {
1213
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_digit ( )
1225
+ match * self {
1226
+ '0' ..='9' => true ,
1227
+ _ => false ,
1228
+ }
1214
1229
}
1215
1230
1216
1231
/// Checks if the value is an ASCII hexadecimal digit:
@@ -1246,7 +1261,10 @@ impl char {
1246
1261
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1247
1262
#[ inline]
1248
1263
pub const fn is_ascii_hexdigit ( & self ) -> bool {
1249
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_hexdigit ( )
1264
+ match * self {
1265
+ '0' ..='9' | 'A' ..='F' | 'a' ..='f' => true ,
1266
+ _ => false ,
1267
+ }
1250
1268
}
1251
1269
1252
1270
/// Checks if the value is an ASCII punctuation character:
@@ -1283,7 +1301,10 @@ impl char {
1283
1301
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1284
1302
#[ inline]
1285
1303
pub const fn is_ascii_punctuation ( & self ) -> bool {
1286
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_punctuation ( )
1304
+ match * self {
1305
+ '!' ..='/' | ':' ..='@' | '[' ..='`' | '{' ..='~' => true ,
1306
+ _ => false ,
1307
+ }
1287
1308
}
1288
1309
1289
1310
/// Checks if the value is an ASCII graphic character:
@@ -1316,7 +1337,10 @@ impl char {
1316
1337
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1317
1338
#[ inline]
1318
1339
pub const fn is_ascii_graphic ( & self ) -> bool {
1319
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_graphic ( )
1340
+ match * self {
1341
+ '!' ..='~' => true ,
1342
+ _ => false ,
1343
+ }
1320
1344
}
1321
1345
1322
1346
/// Checks if the value is an ASCII whitespace character:
@@ -1366,7 +1390,10 @@ impl char {
1366
1390
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1367
1391
#[ inline]
1368
1392
pub const fn is_ascii_whitespace ( & self ) -> bool {
1369
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_whitespace ( )
1393
+ match * self {
1394
+ '\t' | '\n' | '\x0C' | '\r' | ' ' => true ,
1395
+ _ => false ,
1396
+ }
1370
1397
}
1371
1398
1372
1399
/// Checks if the value is an ASCII control character:
@@ -1401,6 +1428,9 @@ impl char {
1401
1428
#[ rustc_const_unstable( feature = "const_ascii_ctype_on_intrinsics" , issue = "68983" ) ]
1402
1429
#[ inline]
1403
1430
pub const fn is_ascii_control ( & self ) -> bool {
1404
- self . is_ascii ( ) && ( * self as u8 ) . is_ascii_control ( )
1431
+ match * self {
1432
+ '\0' ..='\x1F' | '\x7F' => true ,
1433
+ _ => false ,
1434
+ }
1405
1435
}
1406
1436
}
0 commit comments