diff options
| author | Igor Aleksanov <popzxc@yandex.ru> | 2020-01-07 10:35:16 +0300 |
|---|---|---|
| committer | Igor Aleksanov <popzxc@yandex.ru> | 2020-01-08 07:10:28 +0300 |
| commit | f720469fd0c4dff6d92e2f778ea2f252f76dcc2e (patch) | |
| tree | eed0768e1946a78b266025d661016f190795d871 /src/libcore/num/mod.rs | |
| parent | aa0769b92e60f5298f0b6326b8654c9b04351b98 (diff) | |
| download | rust-f720469fd0c4dff6d92e2f778ea2f252f76dcc2e.tar.gz rust-f720469fd0c4dff6d92e2f778ea2f252f76dcc2e.zip | |
Use matches macro in libcore and libstd
Diffstat (limited to 'src/libcore/num/mod.rs')
| -rw-r--r-- | src/libcore/num/mod.rs | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index b6b4a46e0b8..5f8cfc63920 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -4283,10 +4283,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphabetic(&self) -> bool { - match *self { - b'A'..=b'Z' | b'a'..=b'z' => true, - _ => false, - } + matches!(*self, b'A'..=b'Z' | b'a'..=b'z') } /// Checks if the value is an ASCII uppercase character: @@ -4318,10 +4315,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_uppercase(&self) -> bool { - match *self { - b'A'..=b'Z' => true, - _ => false, - } + matches!(*self, b'A'..=b'Z') } /// Checks if the value is an ASCII lowercase character: @@ -4353,10 +4347,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_lowercase(&self) -> bool { - match *self { - b'a'..=b'z' => true, - _ => false, - } + matches!(*self, b'a'..=b'z') } /// Checks if the value is an ASCII alphanumeric character: @@ -4391,10 +4382,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphanumeric(&self) -> bool { - match *self { - b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z' => true, - _ => false, - } + matches!(*self, b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z') } /// Checks if the value is an ASCII decimal digit: @@ -4426,10 +4414,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_digit(&self) -> bool { - match *self { - b'0'..=b'9' => true, - _ => false, - } + matches!(*self, b'0'..=b'9') } /// Checks if the value is an ASCII hexadecimal digit: @@ -4464,10 +4449,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_hexdigit(&self) -> bool { - match *self { - b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f' => true, - _ => false, - } + matches!(*self, b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f') } /// Checks if the value is an ASCII punctuation character: @@ -4503,10 +4485,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_punctuation(&self) -> bool { - match *self { - b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~' => true, - _ => false, - } + matches!(*self, b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~') } /// Checks if the value is an ASCII graphic character: @@ -4538,10 +4517,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_graphic(&self) -> bool { - match *self { - b'!'..=b'~' => true, - _ => false, - } + matches!(*self, b'!'..=b'~') } /// Checks if the value is an ASCII whitespace character: @@ -4590,10 +4566,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_whitespace(&self) -> bool { - match *self { - b'\t' | b'\n' | b'\x0C' | b'\r' | b' ' => true, - _ => false, - } + matches!(*self, b'\t' | b'\n' | b'\x0C' | b'\r' | b' ') } /// Checks if the value is an ASCII control character: @@ -4627,10 +4600,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_control(&self) -> bool { - match *self { - b'\0'..=b'\x1F' | b'\x7F' => true, - _ => false, - } + matches!(*self, b'\0'..=b'\x1F' | b'\x7F') } } |
