From d5e72088bcd53df9887f763113e4aceca86e2897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 2 Apr 2024 17:07:53 +0200 Subject: [PATCH] Use let-else to simplify one match --- src/forward_traffic.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/forward_traffic.rs b/src/forward_traffic.rs index 392ddd3..d0110b6 100644 --- a/src/forward_traffic.rs +++ b/src/forward_traffic.rs @@ -103,10 +103,9 @@ async fn maybe_timeout( async fn forward_datagrams_in_buffer(udp_out: &UdpSocket, buffer: &[u8]) -> io::Result { let mut unprocessed_buffer = buffer; loop { - let (datagram_data, tail) = match split_first_datagram(unprocessed_buffer) { - Some(data_tuple) => data_tuple, + let Some((datagram_data, tail)) = split_first_datagram(unprocessed_buffer) else { // The buffer does not contain the entire datagram - None => break Ok(buffer.len() - unprocessed_buffer.len()), + break Ok(buffer.len() - unprocessed_buffer.len()); }; let udp_write_len = udp_out.send(datagram_data).await?;