Skip to content

Commit

Permalink
use matches macro to generate jump table instead of chain of conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
DXist committed Dec 22, 2024
1 parent 3c0d561 commit 7195078
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sqlx-postgres/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,14 @@ impl PgListener {
// The connection is dead, ensure that it is dropped,
// update self state, and loop to try again.
Err(Error::Io(err))
if (err.kind() == io::ErrorKind::ConnectionAborted
|| err.kind() == io::ErrorKind::UnexpectedEof
if matches!(
err.kind(),
io::ErrorKind::ConnectionAborted |
io::ErrorKind::UnexpectedEof |
// see ERRORS section in tcp(7) man page (https://man7.org/linux/man-pages/man7/tcp.7.html)
|| err.kind() == io::ErrorKind::TimedOut
|| err.kind() == io::ErrorKind::BrokenPipe) =>
io::ErrorKind::TimedOut |
io::ErrorKind::BrokenPipe
) =>
{
if let Some(mut conn) = self.connection.take() {
self.buffer_tx = conn.inner.stream.notifications.take();
Expand Down

0 comments on commit 7195078

Please sign in to comment.