@@ -3958,9 +3958,8 @@ impl u8 {
3958
3958
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
3959
3959
#[ inline]
3960
3960
pub fn is_ascii_alphabetic ( & self ) -> bool {
3961
- if * self >= 0x80 { return false ; }
3962
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
3963
- L | Lx | U | Ux => true ,
3961
+ match * self {
3962
+ b'A' ...b'Z' | b'a' ...b'z' => true ,
3964
3963
_ => false
3965
3964
}
3966
3965
}
@@ -3994,9 +3993,8 @@ impl u8 {
3994
3993
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
3995
3994
#[ inline]
3996
3995
pub fn is_ascii_uppercase ( & self ) -> bool {
3997
- if * self >= 0x80 { return false }
3998
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
3999
- U | Ux => true ,
3996
+ match * self {
3997
+ b'A' ...b'Z' => true ,
4000
3998
_ => false
4001
3999
}
4002
4000
}
@@ -4030,9 +4028,8 @@ impl u8 {
4030
4028
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4031
4029
#[ inline]
4032
4030
pub fn is_ascii_lowercase ( & self ) -> bool {
4033
- if * self >= 0x80 { return false }
4034
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4035
- L | Lx => true ,
4031
+ match * self {
4032
+ b'a' ...b'z' => true ,
4036
4033
_ => false
4037
4034
}
4038
4035
}
@@ -4069,9 +4066,8 @@ impl u8 {
4069
4066
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4070
4067
#[ inline]
4071
4068
pub fn is_ascii_alphanumeric ( & self ) -> bool {
4072
- if * self >= 0x80 { return false }
4073
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4074
- D | L | Lx | U | Ux => true ,
4069
+ match * self {
4070
+ b'0' ...b'9' | b'A' ...b'Z' | b'a' ...b'z' => true ,
4075
4071
_ => false
4076
4072
}
4077
4073
}
@@ -4105,9 +4101,8 @@ impl u8 {
4105
4101
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4106
4102
#[ inline]
4107
4103
pub fn is_ascii_digit ( & self ) -> bool {
4108
- if * self >= 0x80 { return false }
4109
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4110
- D => true ,
4104
+ match * self {
4105
+ b'0' ...b'9' => true ,
4111
4106
_ => false
4112
4107
}
4113
4108
}
@@ -4144,9 +4139,8 @@ impl u8 {
4144
4139
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4145
4140
#[ inline]
4146
4141
pub fn is_ascii_hexdigit ( & self ) -> bool {
4147
- if * self >= 0x80 { return false }
4148
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4149
- D | Lx | Ux => true ,
4142
+ match * self {
4143
+ b'0' ...b'9' | b'A' ...b'F' | b'a' ...b'f' => true ,
4150
4144
_ => false
4151
4145
}
4152
4146
}
@@ -4184,9 +4178,8 @@ impl u8 {
4184
4178
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4185
4179
#[ inline]
4186
4180
pub fn is_ascii_punctuation ( & self ) -> bool {
4187
- if * self >= 0x80 { return false }
4188
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4189
- P => true ,
4181
+ match * self {
4182
+ b'!' ...b'/' | b':' ...b'@' | b'[' ...b'`' | b'{' ...b'~' => true ,
4190
4183
_ => false
4191
4184
}
4192
4185
}
@@ -4220,9 +4213,8 @@ impl u8 {
4220
4213
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4221
4214
#[ inline]
4222
4215
pub fn is_ascii_graphic ( & self ) -> bool {
4223
- if * self >= 0x80 { return false ; }
4224
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4225
- Ux | U | Lx | L | D | P => true ,
4216
+ match * self {
4217
+ b'!' ...b'~' => true ,
4226
4218
_ => false
4227
4219
}
4228
4220
}
@@ -4273,9 +4265,8 @@ impl u8 {
4273
4265
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4274
4266
#[ inline]
4275
4267
pub fn is_ascii_whitespace ( & self ) -> bool {
4276
- if * self >= 0x80 { return false ; }
4277
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4278
- Cw | W => true ,
4268
+ match * self {
4269
+ b'\t' | b'\n' | b'\x0C' | b'\r' | b' ' => true ,
4279
4270
_ => false
4280
4271
}
4281
4272
}
@@ -4311,9 +4302,8 @@ impl u8 {
4311
4302
#[ stable( feature = "ascii_ctype_on_intrinsics" , since = "1.24.0" ) ]
4312
4303
#[ inline]
4313
4304
pub fn is_ascii_control ( & self ) -> bool {
4314
- if * self >= 0x80 { return false ; }
4315
- match ASCII_CHARACTER_CLASS [ * self as usize ] {
4316
- C | Cw => true ,
4305
+ match * self {
4306
+ b'\0' ...b'\x1F' | b'\x7F' => true ,
4317
4307
_ => false
4318
4308
}
4319
4309
}
@@ -4979,28 +4969,3 @@ impl_from! { u32, f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
4979
4969
4980
4970
// Float -> Float
4981
4971
impl_from ! { f32 , f64 , #[ stable( feature = "lossless_float_conv" , since = "1.6.0" ) ] }
4982
-
4983
- enum AsciiCharacterClass {
4984
- C , // control
4985
- Cw , // control whitespace
4986
- W , // whitespace
4987
- D , // digit
4988
- L , // lowercase
4989
- Lx , // lowercase hex digit
4990
- U , // uppercase
4991
- Ux , // uppercase hex digit
4992
- P , // punctuation
4993
- }
4994
- use self :: AsciiCharacterClass :: * ;
4995
-
4996
- static ASCII_CHARACTER_CLASS : [ AsciiCharacterClass ; 128 ] = [
4997
- // _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f
4998
- C , C , C , C , C , C , C , C , C , Cw , Cw , C , Cw , Cw , C , C , // 0_
4999
- C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , // 1_
5000
- W , P , P , P , P , P , P , P , P , P , P , P , P , P , P , P , // 2_
5001
- D , D , D , D , D , D , D , D , D , D , P , P , P , P , P , P , // 3_
5002
- P , Ux , Ux , Ux , Ux , Ux , Ux , U , U , U , U , U , U , U , U , U , // 4_
5003
- U , U , U , U , U , U , U , U , U , U , U , P , P , P , P , P , // 5_
5004
- P , Lx , Lx , Lx , Lx , Lx , Lx , L , L , L , L , L , L , L , L , L , // 6_
5005
- L , L , L , L , L , L , L , L , L , L , L , P , P , P , P , C , // 7_
5006
- ] ;
0 commit comments