Skip to content

Commit

Permalink
refactor(http1): updated Encoder/Decoder match with the matches macro (
Browse files Browse the repository at this point in the history
  • Loading branch information
Polkaverse authored and Benxiang Ge committed Jul 26, 2021
1 parent 5b8af65 commit 98eaa00
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
5 changes: 1 addition & 4 deletions src/proto/h1/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<R: MemRead>(
Expand Down
5 changes: 1 addition & 4 deletions src/proto/h1/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
7 changes: 2 additions & 5 deletions src/server/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 98eaa00

Please sign in to comment.