Skip to content

Commit

Permalink
Use let-else to simplify one match
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Apr 2, 2024
1 parent 0fb7951 commit d5e7208
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/forward_traffic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ async fn maybe_timeout<F: Future>(
async fn forward_datagrams_in_buffer(udp_out: &UdpSocket, buffer: &[u8]) -> io::Result<usize> {
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?;
Expand Down

0 comments on commit d5e7208

Please sign in to comment.