diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-07-15 13:09:41 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-07-15 14:56:58 +0200 |
| commit | ebe328d1724a63c6d93df2155195ba7c5558fde2 (patch) | |
| tree | 78a6f14dc59eedea90f7065989ccf04164378dc5 | |
| parent | de3b988970d47625cffb4497d4d425fa3a6d0a4b (diff) | |
| download | mullvadvpn-ebe328d1724a63c6d93df2155195ba7c5558fde2.tar.xz mullvadvpn-ebe328d1724a63c6d93df2155195ba7c5558fde2.zip | |
Fix `collapsible_if` clippy lint
| -rw-r--r-- | mullvad-api/src/access.rs | 12 | ||||
| -rw-r--r-- | mullvad-api/src/proxy.rs | 14 | ||||
| -rw-r--r-- | mullvad-api/src/relay_list.rs | 109 | ||||
| -rw-r--r-- | mullvad-api/src/rest.rs | 25 | ||||
| -rw-r--r-- | mullvad-leak-checker/src/traceroute/unix/linux.rs | 8 | ||||
| -rw-r--r-- | mullvad-masque-proxy/src/server/mod.rs | 34 | ||||
| -rw-r--r-- | talpid-core/src/firewall/linux.rs | 13 | ||||
| -rw-r--r-- | talpid-core/src/logging/mod.rs | 16 | ||||
| -rw-r--r-- | talpid-core/src/tunnel_state_machine/connecting_state.rs | 8 | ||||
| -rw-r--r-- | talpid-dbus/src/network_manager.rs | 8 | ||||
| -rw-r--r-- | talpid-future/src/retry.rs | 28 | ||||
| -rw-r--r-- | talpid-openvpn/src/lib.rs | 14 | ||||
| -rw-r--r-- | talpid-openvpn/src/mktemp.rs | 16 | ||||
| -rw-r--r-- | talpid-platform-metadata/src/linux.rs | 11 | ||||
| -rw-r--r-- | talpid-routing/src/unix/linux.rs | 53 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_kernel/mod.rs | 13 | ||||
| -rw-r--r-- | wireguard-go-rs/build.rs | 9 |
17 files changed, 194 insertions, 197 deletions
diff --git a/mullvad-api/src/access.rs b/mullvad-api/src/access.rs index 6c875ad1e8..1ee6ea612d 100644 --- a/mullvad-api/src/access.rs +++ b/mullvad-api/src/access.rs @@ -155,12 +155,12 @@ impl AccessTokenStore { /// Remove an access token if the API response calls for it. pub fn check_response<T>(&self, account: &AccountNumber, response: &Result<T, rest::Error>) { - if let Err(rest::Error::ApiError(_status, code)) = response { - if code == crate::INVALID_ACCESS_TOKEN { - let _ = self - .tx - .unbounded_send(StoreAction::InvalidateToken(account.to_owned())); - } + if let Err(rest::Error::ApiError(_status, code)) = response + && code == crate::INVALID_ACCESS_TOKEN + { + let _ = self + .tx + .unbounded_send(StoreAction::InvalidateToken(account.to_owned())); } } } diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs index 4ad842ee85..ab05e25021 100644 --- a/mullvad-api/src/proxy.rs +++ b/mullvad-api/src/proxy.rs @@ -154,13 +154,13 @@ impl ApiConnectionMode { /// Attempts to remove `CURRENT_CONFIG_FILENAME`, if it exists. pub async fn try_delete_cache(cache_dir: &Path) { let path = cache_dir.join(CURRENT_CONFIG_FILENAME); - if let Err(err) = fs::remove_file(path).await { - if err.kind() != std::io::ErrorKind::NotFound { - log::error!( - "{}", - err.display_chain_with_msg("Failed to remove old API config") - ); - } + if let Err(err) = fs::remove_file(path).await + && err.kind() != std::io::ErrorKind::NotFound + { + log::error!( + "{}", + err.display_chain_with_msg("Failed to remove old API config") + ); } } diff --git a/mullvad-api/src/relay_list.rs b/mullvad-api/src/relay_list.rs index 799a55dc1a..abca6dd2b7 100644 --- a/mullvad-api/src/relay_list.rs +++ b/mullvad-api/src/relay_list.rs @@ -209,26 +209,24 @@ impl OpenVpn { ) -> relay_list::OpenVpnEndpointData { for mut openvpn_relay in self.relays.into_iter() { openvpn_relay.convert_to_lowercase(); - if let Some((country_code, city_code)) = split_location_code(&openvpn_relay.location) { - if let Some(country) = countries.get_mut(country_code) { - if let Some(city) = country - .cities - .iter_mut() - .find(|city| city.code == city_code) - { - let location = location::Location { - country: country.name.clone(), - country_code: country.code.clone(), - city: city.name.clone(), - city_code: city.code.clone(), - latitude: city.latitude, - longitude: city.longitude, - }; - let relay = openvpn_relay.into_openvpn_mullvad_relay(location); - city.relays.push(relay); - } + if let Some((country_code, city_code)) = split_location_code(&openvpn_relay.location) + && let Some(country) = countries.get_mut(country_code) + && let Some(city) = country + .cities + .iter_mut() + .find(|city| city.code == city_code) + { + let location = location::Location { + country: country.name.clone(), + country_code: country.code.clone(), + city: city.name.clone(), + city_code: city.code.clone(), + latitude: city.latitude, + longitude: city.longitude, }; - } + let relay = openvpn_relay.into_openvpn_mullvad_relay(location); + city.relays.push(relay); + }; } self.ports } @@ -321,27 +319,24 @@ impl Wireguard { wireguard_relay.relay.convert_to_lowercase(); if let Some((country_code, city_code)) = split_location_code(&wireguard_relay.relay.location) + && let Some(country) = countries.get_mut(country_code) + && let Some(city) = country + .cities + .iter_mut() + .find(|city| city.code == city_code) { - if let Some(country) = countries.get_mut(country_code) { - if let Some(city) = country - .cities - .iter_mut() - .find(|city| city.code == city_code) - { - let location = location::Location { - country: country.name.clone(), - country_code: country.code.clone(), - city: city.name.clone(), - city_code: city.code.clone(), - latitude: city.latitude, - longitude: city.longitude, - }; - - let relay = wireguard_relay.into_mullvad_relay(location); - city.relays.push(relay); - } + let location = location::Location { + country: country.name.clone(), + country_code: country.code.clone(), + city: city.name.clone(), + city_code: city.code.clone(), + latitude: city.latitude, + longitude: city.longitude, }; - } + + let relay = wireguard_relay.into_mullvad_relay(location); + city.relays.push(relay); + }; } endpoint_data @@ -394,27 +389,25 @@ impl Bridges { ) -> relay_list::BridgeEndpointData { for mut bridge_relay in self.relays { bridge_relay.convert_to_lowercase(); - if let Some((country_code, city_code)) = split_location_code(&bridge_relay.location) { - if let Some(country) = countries.get_mut(country_code) { - if let Some(city) = country - .cities - .iter_mut() - .find(|city| city.code == city_code) - { - let location = location::Location { - country: country.name.clone(), - country_code: country.code.clone(), - city: city.name.clone(), - city_code: city.code.clone(), - latitude: city.latitude, - longitude: city.longitude, - }; - - let relay = bridge_relay.into_bridge_mullvad_relay(location); - city.relays.push(relay); - } + if let Some((country_code, city_code)) = split_location_code(&bridge_relay.location) + && let Some(country) = countries.get_mut(country_code) + && let Some(city) = country + .cities + .iter_mut() + .find(|city| city.code == city_code) + { + let location = location::Location { + country: country.name.clone(), + country_code: country.code.clone(), + city: city.name.clone(), + city_code: city.code.clone(), + latitude: city.latitude, + longitude: city.longitude, }; - } + + let relay = bridge_relay.into_bridge_mullvad_relay(location); + city.relays.push(relay); + }; } relay_list::BridgeEndpointData { diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index 5e7d13047e..3854f66ef4 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -101,11 +101,12 @@ impl Error { pub fn is_offline(&self) -> bool { match self { Error::LegacyHyperError(error) if error.is_connect() => { - if let Some(cause) = error.source() { - if let Some(err) = cause.downcast_ref::<std::io::Error>() { - return err.raw_os_error() == Some(libc::ENETUNREACH); - } + if let Some(cause) = error.source() + && let Some(err) = cause.downcast_ref::<std::io::Error>() + { + return err.raw_os_error() == Some(libc::ENETUNREACH); } + false } // TODO: Currently, we use the legacy hyper client for all REST requests. If this @@ -252,14 +253,14 @@ impl<T: ConnectionModeProvider + 'static> RequestService<T> { let response = request_future.await.map_err(|error| error.map_aborted()); // Switch API endpoint if the request failed due to a network error - if let Err(err) = &response { - if err.is_network_error() && !api_availability.is_offline() { - log::error!("{}", err.display_chain_with_msg("HTTP request failed")); - if let Some(tx) = tx { - let _ = tx.unbounded_send(RequestCommand::NextApiConfig( - connection_mode_generation, - )); - } + if let Err(err) = &response + && err.is_network_error() + && !api_availability.is_offline() + { + log::error!("{}", err.display_chain_with_msg("HTTP request failed")); + if let Some(tx) = tx { + let _ = tx + .unbounded_send(RequestCommand::NextApiConfig(connection_mode_generation)); } } diff --git a/mullvad-leak-checker/src/traceroute/unix/linux.rs b/mullvad-leak-checker/src/traceroute/unix/linux.rs index 6df2dbaa4a..30ed579adf 100644 --- a/mullvad-leak-checker/src/traceroute/unix/linux.rs +++ b/mullvad-leak-checker/src/traceroute/unix/linux.rs @@ -141,10 +141,10 @@ async fn recv_ttl_responses( // Call recvmsg in a loop let recv_packet = loop { - if let Some(timeout_at) = timeout_at { - if Instant::now() >= timeout_at { - break 'outer; - } + if let Some(timeout_at) = timeout_at + && Instant::now() >= timeout_at + { + break 'outer; } let recv_packet = match destination { diff --git a/mullvad-masque-proxy/src/server/mod.rs b/mullvad-masque-proxy/src/server/mod.rs index 205b7b912f..f8f224d485 100644 --- a/mullvad-masque-proxy/src/server/mod.rs +++ b/mullvad-masque-proxy/src/server/mod.rs @@ -186,26 +186,26 @@ impl Server { } } - if let Some(hostname) = &server_params.hostname { - if &proxy_uri.hostname != hostname { - let valid_uri = ProxyUri { - hostname: hostname.to_string(), - ..proxy_uri - }; + if let Some(hostname) = &server_params.hostname + && &proxy_uri.hostname != hostname + { + let valid_uri = ProxyUri { + hostname: hostname.to_string(), + ..proxy_uri + }; - respond_with_redirect(stream, valid_uri).await; + respond_with_redirect(stream, valid_uri).await; - // NOTE: Recursing like this makes us vulnerable to DoS if the client keeps - // sending the wrong hostname. This is fine since this is just an example server. - Box::pin(Self::accept_proxy_request( - quic_conn, - http_conn, - server_params, - )) - .await; + // NOTE: Recursing like this makes us vulnerable to DoS if the client keeps + // sending the wrong hostname. This is fine since this is just an example server. + Box::pin(Self::accept_proxy_request( + quic_conn, + http_conn, + server_params, + )) + .await; - return; - } + return; } if !server_params diff --git a/talpid-core/src/firewall/linux.rs b/talpid-core/src/firewall/linux.rs index 53dd63fe0b..1a418e8ca6 100644 --- a/talpid-core/src/firewall/linux.rs +++ b/talpid-core/src/firewall/linux.rs @@ -148,10 +148,10 @@ impl Firewall { fn apply_kernel_config(policy: &FirewallPolicy) { if *DONT_SET_SRC_VALID_MARK { log::debug!("Not setting src_valid_mark"); - } else if let FirewallPolicy::Connecting { .. } = policy { - if let Err(err) = set_src_valid_mark_sysctl() { - log::error!("Failed to apply src_valid_mark: {}", err); - } + } else if let FirewallPolicy::Connecting { .. } = policy + && let Err(err) = set_src_valid_mark_sysctl() + { + log::error!("Failed to apply src_valid_mark: {}", err); } // When we have a tunnel with an IP configured, we configure the system @@ -166,10 +166,9 @@ impl Firewall { if *DONT_SET_ARP_IGNORE { log::debug!("Not setting arp_ignore"); } else if let FirewallPolicy::Connecting { .. } | FirewallPolicy::Connected { .. } = policy + && let Err(err) = lock_down_arp_ignore_sysctl() { - if let Err(err) = lock_down_arp_ignore_sysctl() { - log::error!("Failed to apply arp_ignore: {}", err); - } + log::error!("Failed to apply arp_ignore: {}", err); } } diff --git a/talpid-core/src/logging/mod.rs b/talpid-core/src/logging/mod.rs index 0e15054dd4..bd09c9dc03 100644 --- a/talpid-core/src/logging/mod.rs +++ b/talpid-core/src/logging/mod.rs @@ -11,14 +11,14 @@ pub struct RotateLogError(#[from] io::Error); /// it is backed up with the extension changed to `.old.log`. pub fn rotate_log(file: &Path) -> Result<(), RotateLogError> { let backup = file.with_extension("old.log"); - if let Err(error) = fs::rename(file, &backup) { - if error.kind() != io::ErrorKind::NotFound { - log::warn!( - "Failed to rotate log file to {}: {}", - backup.display(), - error - ); - } + if let Err(error) = fs::rename(file, &backup) + && error.kind() != io::ErrorKind::NotFound + { + log::warn!( + "Failed to rotate log file to {}: {}", + backup.display(), + error + ); } fs::File::create(file).map(|_| ()).map_err(RotateLogError) diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs index 9ce22a6285..8f26c92b9d 100644 --- a/talpid-core/src/tunnel_state_machine/connecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs @@ -272,10 +272,10 @@ impl ConnectingState { } }; - if block_reason.is_none() { - if let Some(remaining_time) = MIN_TUNNEL_ALIVE_TIME.checked_sub(start.elapsed()) { - thread::sleep(remaining_time); - } + if block_reason.is_none() + && let Some(remaining_time) = MIN_TUNNEL_ALIVE_TIME.checked_sub(start.elapsed()) + { + thread::sleep(remaining_time); } if tunnel_close_event_tx.send(block_reason).is_err() { diff --git a/talpid-dbus/src/network_manager.rs b/talpid-dbus/src/network_manager.rs index df49c3cd2b..cd16677670 100644 --- a/talpid-dbus/src/network_manager.rs +++ b/talpid-dbus/src/network_manager.rs @@ -560,10 +560,10 @@ impl NetworkManager { Self::update_dns_config(&mut settings, "ipv6", v6_dns); } - if let Some(wg_config) = settings.get_mut("wireguard") { - if !wg_config.contains_key("fwmark") { - log::error!("WireGuard config doesn't contain the firewall mark"); - } + if let Some(wg_config) = settings.get_mut("wireguard") + && !wg_config.contains_key("fwmark") + { + log::error!("WireGuard config doesn't contain the firewall mark"); } self.reapply_settings(&device_path, settings, version_id)?; diff --git a/talpid-future/src/retry.rs b/talpid-future/src/retry.rs index f2d7d2a3e2..def46d5bc2 100644 --- a/talpid-future/src/retry.rs +++ b/talpid-future/src/retry.rs @@ -18,12 +18,13 @@ pub async fn retry_future< ) -> T { loop { let current_result = factory().await; - if should_retry(¤t_result) { - if let Some(delay) = delays.next() { - sleep(delay).await; - continue; - } + if should_retry(¤t_result) + && let Some(delay) = delays.next() + { + sleep(delay).await; + continue; } + return current_result; } } @@ -50,11 +51,12 @@ impl Iterator for ConstantInterval { type Item = Duration; fn next(&mut self) -> Option<Duration> { - if let Some(max_attempts) = self.max_attempts { - if self.attempt >= max_attempts { - return None; - } + if let Some(max_attempts) = self.max_attempts + && self.attempt >= max_attempts + { + return None; } + self.attempt = self.attempt.saturating_add(1); Some(self.interval) } @@ -92,10 +94,10 @@ impl ExponentialBackoff { fn next_delay(&mut self) -> Duration { let next = self.next; - if let Some(max_delay) = self.max_delay { - if next > max_delay { - return max_delay; - } + if let Some(max_delay) = self.max_delay + && next > max_delay + { + return max_delay; } self.next = next.saturating_mul(self.factor); diff --git a/talpid-openvpn/src/lib.rs b/talpid-openvpn/src/lib.rs index 29ec3d44bd..30103d59a4 100644 --- a/talpid-openvpn/src/lib.rs +++ b/talpid-openvpn/src/lib.rs @@ -543,14 +543,14 @@ impl<C: OpenVpnBuilder + Send + 'static> OpenVpnMonitor<C> { fn create_proxy_auth_file( proxy_settings: &Option<CustomProxy>, ) -> std::result::Result<Option<mktemp::TempFile>, io::Error> { - if let Some(CustomProxy::Socks5Remote(remote_proxy)) = proxy_settings { - if let Some(ref proxy_auth) = remote_proxy.auth { - return Ok(Some(Self::create_credentials_file( - proxy_auth.username(), - proxy_auth.password(), - )?)); - } + if let Some(CustomProxy::Socks5Remote(remote_proxy)) = proxy_settings + && let Some(ref proxy_auth) = remote_proxy.auth + { + let credentials_file = + Self::create_credentials_file(proxy_auth.username(), proxy_auth.password())?; + return Ok(Some(credentials_file)); } + Ok(None) } diff --git a/talpid-openvpn/src/mktemp.rs b/talpid-openvpn/src/mktemp.rs index 9e5709ce1f..c7c8454908 100644 --- a/talpid-openvpn/src/mktemp.rs +++ b/talpid-openvpn/src/mktemp.rs @@ -31,14 +31,14 @@ impl AsRef<Path> for TempFile { impl Drop for TempFile { fn drop(&mut self) { - if let Err(e) = fs::remove_file(&self.path) { - if e.kind() != io::ErrorKind::NotFound { - log::error!( - "Unable to remove temp file {}: {:?}", - self.path.display(), - e - ); - } + if let Err(e) = fs::remove_file(&self.path) + && e.kind() != io::ErrorKind::NotFound + { + log::error!( + "Unable to remove temp file {}: {:?}", + self.path.display(), + e + ); } } } diff --git a/talpid-platform-metadata/src/linux.rs b/talpid-platform-metadata/src/linux.rs index 664ba394af..e032daf97f 100644 --- a/talpid-platform-metadata/src/linux.rs +++ b/talpid-platform-metadata/src/linux.rs @@ -30,12 +30,11 @@ fn read_os_release_file_short() -> Option<String> { let os_name = os_release_info.remove("NAME"); let os_version_id = os_release_info.remove("VERSION_ID"); - if let Some(os_name) = os_name { - if os_name != "NixOS" { - if let Some(os_version_id) = os_version_id { - return Some(format!("{os_name} {os_version_id}")); - } - } + if let Some(os_name) = os_name + && os_name != "NixOS" + && let Some(os_version_id) = os_version_id + { + return Some(format!("{os_name} {os_version_id}")); } os_release_info.remove("PRETTY_NAME") diff --git a/talpid-routing/src/unix/linux.rs b/talpid-routing/src/unix/linux.rs index 8340e4534d..186fa07188 100644 --- a/talpid-routing/src/unix/linux.rs +++ b/talpid-routing/src/unix/linux.rs @@ -273,10 +273,10 @@ impl RouteManagerImpl { let mut response = self.handle.request(req).map_err(Error::Netlink)?; while let Some(message) = response.next().await { - if let NetlinkPayload::Error(error) = message.payload { - if error.to_io().kind() != io::ErrorKind::NotFound { - return Err(Error::Netlink(rtnetlink::Error::NetlinkError(error))); - } + if let NetlinkPayload::Error(error) = message.payload + && error.to_io().kind() != io::ErrorKind::NotFound + { + return Err(Error::Netlink(rtnetlink::Error::NetlinkError(error))); } } Ok(()) @@ -565,11 +565,12 @@ impl RouteManagerImpl { async fn delete_route_if_exists(&self, route: &Route) -> Result<()> { if let Err(error) = self.delete_route(route).await { - if let Error::Netlink(rtnetlink::Error::NetlinkError(msg)) = &error { - if msg.code == -libc::ESRCH { - return Ok(()); - } + if let Error::Netlink(rtnetlink::Error::NetlinkError(msg)) = &error + && msg.code == -libc::ESRCH + { + return Ok(()); } + Err(error) } else { Ok(()) @@ -617,10 +618,10 @@ impl RouteManagerImpl { route_message.nlas.push(RouteNla::Table(route.table_id)); } - if let Some(interface_name) = route.node.get_device() { - if let Some(iface_idx) = self.find_iface_idx(interface_name) { - route_message.nlas.push(RouteNla::Oif(iface_idx)); - } + if let Some(interface_name) = route.node.get_device() + && let Some(iface_idx) = self.find_iface_idx(interface_name) + { + route_message.nlas.push(RouteNla::Oif(iface_idx)); } if let Some(gateway) = route.node.get_address() { @@ -662,10 +663,10 @@ impl RouteManagerImpl { add_message = add_message.gateway(node_address); } - if let Some(interface_name) = route.node.get_device() { - if let Some(iface_idx) = self.find_iface_idx(interface_name) { - add_message = add_message.output_interface(iface_idx); - } + if let Some(interface_name) = route.node.get_device() + && let Some(iface_idx) = self.find_iface_idx(interface_name) + { + add_message = add_message.output_interface(iface_idx); } add_message.message_mut().clone() @@ -687,10 +688,10 @@ impl RouteManagerImpl { add_message = add_message.gateway(node_address); } - if let Some(interface_name) = route.node.get_device() { - if let Some(iface_idx) = self.find_iface_idx(interface_name) { - add_message = add_message.output_interface(iface_idx); - } + if let Some(interface_name) = route.node.get_device() + && let Some(iface_idx) = self.find_iface_idx(interface_name) + { + add_message = add_message.output_interface(iface_idx); } add_message.message_mut().clone() @@ -807,13 +808,13 @@ impl RouteManagerImpl { let target_device = LinkNla::IfName(device); while let Some(msg) = links.try_next().await.map_err(|_| Error::LinkNotFound)? { let found = msg.nlas.contains(&target_device); - if found { - if let Some(LinkNla::Mtu(mtu)) = + if found + && let Some(LinkNla::Mtu(mtu)) = msg.nlas.iter().find(|e| matches!(e, LinkNla::Mtu(_))) - { - return Ok(u16::try_from(*mtu) - .expect("MTU returned by device does not fit into a u16")); - } + { + return Ok( + u16::try_from(*mtu).expect("MTU returned by device does not fit into a u16") + ); } } Err(Error::LinkNotFound) diff --git a/talpid-wireguard/src/wireguard_kernel/mod.rs b/talpid-wireguard/src/wireguard_kernel/mod.rs index 90872afb94..eb2ebe0f5d 100644 --- a/talpid-wireguard/src/wireguard_kernel/mod.rs +++ b/talpid-wireguard/src/wireguard_kernel/mod.rs @@ -134,15 +134,16 @@ impl Handle { .request(message, SocketAddr::new(0, 0)) .map_err(Error::NetlinkRequest)?; let response = req.next().await; - if let Some(response) = response { - if let NetlinkPayload::InnerMessage(msg) = response.payload { - for nla in msg.nlas.into_iter() { - if let ControlNla::FamilyId(id) = nla { - return Ok(id); - } + if let Some(response) = response + && let NetlinkPayload::InnerMessage(msg) = response.payload + { + for nla in msg.nlas.into_iter() { + if let ControlNla::FamilyId(id) = nla { + return Ok(id); } } } + Err(Error::WireguardNetlinkInterfaceUnavailable) } .await; diff --git a/wireguard-go-rs/build.rs b/wireguard-go-rs/build.rs index f7a7d9d6a2..c1aaf71485 100644 --- a/wireguard-go-rs/build.rs +++ b/wireguard-go-rs/build.rs @@ -362,11 +362,12 @@ fn find_file( for path in std::fs::read_dir(dir).context("Failed to read dir")? { let entry = path.context("Failed to read dir entry")?; let path = entry.path(); - if path.is_dir() { - if let Some(result) = find_file(&path, condition)? { - return Ok(Some(result)); - } + if path.is_dir() + && let Some(result) = find_file(&path, condition)? + { + return Ok(Some(result)); } + if condition(&path) { return Ok(Some(path.to_owned())); } |
