From 383058268e7e18eb84a30a247b27d556f2cf9026 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 | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tokio/tests/uds_datagram.rs b/tokio/tests/uds_datagram.rs index 5628a00edf0..4d2846865f5 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) => { @@ -297,14 +294,11 @@ async fn try_recv_buf_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) => {