Skip to content

Commit 3b3077d

Browse files
authored
refactor(http1): updated Encoder/Decoder match with the matches macro (#2368)
1 parent 6c593c2 commit 3b3077d

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

src/proto/h1/decode.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ impl Decoder {
9494
// methods
9595

9696
pub fn is_eof(&self) -> bool {
97-
match self.kind {
98-
Length(0) | Chunked(ChunkedState::End, _) | Eof(true) => true,
99-
_ => false,
100-
}
97+
matches!(self.kind, Length(0) | Chunked(ChunkedState::End, _) | Eof(true))
10198
}
10299

103100
pub fn decode<R: MemRead>(

src/proto/h1/encode.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ impl Encoder {
6868
}
6969

7070
pub fn is_eof(&self) -> bool {
71-
match self.kind {
72-
Kind::Length(0) => true,
73-
_ => false,
74-
}
71+
matches!(self.kind, Kind::Length(0))
7572
}
7673

7774
#[cfg(feature = "server")]

src/server/tcp.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,9 @@ impl Accept for AddrIncoming {
202202
/// The timeout is useful to handle resource exhaustion errors like ENFILE
203203
/// and EMFILE. Otherwise, could enter into tight loop.
204204
fn is_connection_error(e: &io::Error) -> bool {
205-
match e.kind() {
206-
io::ErrorKind::ConnectionRefused
205+
matches!(e.kind(), io::ErrorKind::ConnectionRefused
207206
| io::ErrorKind::ConnectionAborted
208-
| io::ErrorKind::ConnectionReset => true,
209-
_ => false,
210-
}
207+
| io::ErrorKind::ConnectionReset)
211208
}
212209

213210
impl fmt::Debug for AddrIncoming {

0 commit comments

Comments
 (0)