From 98eaa003817c8e4266faf6b21a5b4e798cefc36a Mon Sep 17 00:00:00 2001 From: Pankaj Chaudhary Date: Wed, 23 Dec 2020 00:20:57 +0530 Subject: [PATCH] refactor(http1): updated Encoder/Decoder match with the matches macro (#2368) --- src/proto/h1/decode.rs | 5 +---- src/proto/h1/encode.rs | 5 +---- src/server/tcp.rs | 7 ++----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/proto/h1/decode.rs b/src/proto/h1/decode.rs index ddca5f9d60..73b5dd4ded 100644 --- a/src/proto/h1/decode.rs +++ b/src/proto/h1/decode.rs @@ -94,10 +94,7 @@ impl Decoder { // methods pub fn is_eof(&self) -> bool { - match self.kind { - Length(0) | Chunked(ChunkedState::End, _) | Eof(true) => true, - _ => false, - } + matches!(self.kind, Length(0) | Chunked(ChunkedState::End, _) | Eof(true)) } pub fn decode( diff --git a/src/proto/h1/encode.rs b/src/proto/h1/encode.rs index d165527ea9..0f0ccca73e 100644 --- a/src/proto/h1/encode.rs +++ b/src/proto/h1/encode.rs @@ -68,10 +68,7 @@ impl Encoder { } pub fn is_eof(&self) -> bool { - match self.kind { - Kind::Length(0) => true, - _ => false, - } + matches!(self.kind, Kind::Length(0)) } #[cfg(feature = "server")] diff --git a/src/server/tcp.rs b/src/server/tcp.rs index 6fc5463a34..4111573671 100644 --- a/src/server/tcp.rs +++ b/src/server/tcp.rs @@ -202,12 +202,9 @@ impl Accept for AddrIncoming { /// The timeout is useful to handle resource exhaustion errors like ENFILE /// and EMFILE. Otherwise, could enter into tight loop. fn is_connection_error(e: &io::Error) -> bool { - match e.kind() { - io::ErrorKind::ConnectionRefused + matches!(e.kind(), io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionAborted - | io::ErrorKind::ConnectionReset => true, - _ => false, - } + | io::ErrorKind::ConnectionReset) } impl fmt::Debug for AddrIncoming {