diff options
| author | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-09-12 20:01:44 +0200 |
|---|---|---|
| committer | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-09-15 11:08:31 +0200 |
| commit | 2aedc93c417ee8af682a8f5bae09ee42552fbfcb (patch) | |
| tree | fedf61e730dd31a3b768a5a8af47960541c80ba6 /test | |
| parent | e93d2fcedb5895657f3dfc672f29e98de821e357 (diff) | |
| download | mullvadvpn-2aedc93c417ee8af682a8f5bae09ee42552fbfcb.tar.xz mullvadvpn-2aedc93c417ee8af682a8f5bae09ee42552fbfcb.zip | |
Flatten match statement
Diffstat (limited to 'test')
| -rw-r--r-- | test/test-manager/src/network_monitor.rs | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/test/test-manager/src/network_monitor.rs b/test/test-manager/src/network_monitor.rs index e89c33fb34..64e1414b5c 100644 --- a/test/test-manager/src/network_monitor.rs +++ b/test/test-manager/src/network_monitor.rs @@ -284,29 +284,26 @@ async fn start_packet_monitor_for_interface( break Ok(monitor_result); } maybe_next_packet = next_packet => { - match maybe_next_packet { - Some(Ok(packet))=> { - if let Some(packet) = packet { - if !filter_fn(&packet) { - log::trace!("{interface} \"{packet:?}\" does not match closure conditions"); - monitor_result.discarded_packets = - monitor_result.discarded_packets.saturating_add(1); - } else { - log::trace!("{interface} \"{packet:?}\" matches closure conditions"); + let Some(Ok(packet)) = maybe_next_packet else { + log::error!("lost packet stream"); + break Err(MonitorUnexpectedlyStopped); + }; - let should_continue = should_continue_fn(&packet); + let Some(packet) = packet else { continue }; - monitor_result.packets.push(packet); + if !filter_fn(&packet) { + log::trace!("{interface} \"{packet:?}\" does not match closure conditions"); + monitor_result.discarded_packets = + monitor_result.discarded_packets.saturating_add(1); + } else { + log::trace!("{interface} \"{packet:?}\" matches closure conditions"); - if !should_continue { - break Ok(monitor_result); - } - } - } - } - _ => { - log::error!("lost packet stream"); - break Err(MonitorUnexpectedlyStopped); + let should_continue = should_continue_fn(&packet); + + monitor_result.packets.push(packet); + + if !should_continue { + break Ok(monitor_result); } } } |
