Use 'matches!' macro where possible.

This commit is contained in:
=?UTF-8?q?R=C3=A9mi=20Lauzier?= 2022-02-23 14:11:36 -08:00 committed by Sergio Benitez
parent 928d51ca6e
commit f82d760b52
2 changed files with 4 additions and 9 deletions

View File

@ -167,13 +167,11 @@ impl<L: Listener> Accept for Incoming<L> {
/// The delay is useful to handle resource exhaustion errors like ENFILE /// The delay is useful to handle resource exhaustion errors like ENFILE
/// and EMFILE. Otherwise, could enter into tight loop. /// and EMFILE. Otherwise, could enter into tight loop.
fn is_connection_error(e: &io::Error) -> bool { fn is_connection_error(e: &io::Error) -> bool {
match e.kind() { matches!(e.kind(),
io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionRefused |
io::ErrorKind::ConnectionAborted | io::ErrorKind::ConnectionAborted |
io::ErrorKind::ConnectionReset => true, io::ErrorKind::ConnectionReset)
_ => false,
} }
}
impl<L: fmt::Debug> fmt::Debug for Incoming<L> { impl<L: fmt::Debug> fmt::Debug for Incoming<L> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View File

@ -5,9 +5,6 @@ pub fn is_whitespace(&byte: &char) -> bool {
#[inline] #[inline]
pub fn is_valid_token(&c: &char) -> bool { pub fn is_valid_token(&c: &char) -> bool {
match c { matches!(c, '0'..='9' | 'A'..='Z' | '^'..='~' | '#'..='\''
'0'..='9' | 'A'..='Z' | '^'..='~' | '#'..='\'' | '!' | '*' | '+' | '-' | '.')
| '!' | '*' | '+' | '-' | '.' => true,
_ => false
} }
}