From fb7e888f522b2b638cedcffb75d92b359e43c868 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 11 Jul 2021 07:01:57 -0600 Subject: [PATCH] Condense the error matching block --- tokio/tests/uds_datagram.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tokio/tests/uds_datagram.rs b/tokio/tests/uds_datagram.rs index 5628a00edf0..a0630ed6762 100644 --- a/tokio/tests/uds_datagram.rs +++ b/tokio/tests/uds_datagram.rs @@ -87,14 +87,11 @@ async fn try_send_recv_never_block() -> io::Result<()> { dgram1.writable().await.unwrap(); match dgram1.try_send(payload) { - Err(err) => match err.kind() { - io::ErrorKind::WouldBlock => break, + Err(err) => match (err.kind(), err.raw_os_error()) { + (io::ErrorKind::WouldBlock, _) => break, + (_, Some(libc::ENOBUFS)) => break, _ => { - let errno = err.raw_os_error().expect("Not an errno?"); - if errno == libc::ENOBUFS { - break; - } - unreachable!("unexpected error {:?}", err); + panic!("unexpected error {:?}", err); } }, Ok(len) => {