From 77b2c41518396b1e7c9d75d3c3e314b9248cafc3 Mon Sep 17 00:00:00 2001 From: Datong Sun Date: Fri, 22 Aug 2025 09:17:07 -0700 Subject: [PATCH] style(phantun): use Rust 2024 `&&` combination for `if let` --- phantun/src/bin/client.rs | 5 ++--- phantun/src/bin/server.rs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/phantun/src/bin/client.rs b/phantun/src/bin/client.rs index 2219953..e18d7a1 100644 --- a/phantun/src/bin/client.rs +++ b/phantun/src/bin/client.rs @@ -245,13 +245,12 @@ async fn main() -> io::Result<()> { res = sock.recv(&mut buf_tcp) => { match res { Some(size) => { - if size > 0 { - if let Err(e) = udp_sock.send(&buf_tcp[..size]).await { + if size > 0 + && let Err(e) = udp_sock.send(&buf_tcp[..size]).await { error!("Unable to send UDP packet to {}: {}, closing connection", e, addr); quit.cancel(); return; } - } }, None => { debug!("removed fake TCP socket from connections table"); diff --git a/phantun/src/bin/server.rs b/phantun/src/bin/server.rs index 5160d0e..960fb99 100644 --- a/phantun/src/bin/server.rs +++ b/phantun/src/bin/server.rs @@ -219,13 +219,12 @@ async fn main() -> io::Result<()> { res = sock.recv(&mut buf_tcp) => { match res { Some(size) => { - if size > 0 { - if let Err(e) = udp_sock.send(&buf_tcp[..size]).await { + if size > 0 + && let Err(e) = udp_sock.send(&buf_tcp[..size]).await { error!("Unable to send UDP packet to {}: {}, closing connection", e, remote_addr); quit.cancel(); return; } - } }, None => { quit.cancel();