diff --git a/hostsfile/src/lib.rs b/hostsfile/src/lib.rs index b6ba2e1..a509dea 100644 --- a/hostsfile/src/lib.rs +++ b/hostsfile/src/lib.rs @@ -97,7 +97,7 @@ impl HostsBuilder { /// Adds a mapping of `ip` to `hostname`. If there hostnames associated with the IP already, /// the hostname will be appended to the list. pub fn add_hostname(&mut self, ip: IpAddr, hostname: S) { - let hostnames_dest = self.hostname_map.entry(ip).or_insert_with(Vec::new); + let hostnames_dest = self.hostname_map.entry(ip).or_default(); hostnames_dest.push(hostname.to_string()); } @@ -108,7 +108,7 @@ impl HostsBuilder { ip: IpAddr, hostnames: I, ) { - let hostnames_dest = self.hostname_map.entry(ip).or_insert_with(Vec::new); + let hostnames_dest = self.hostname_map.entry(ip).or_default(); for hostname in hostnames.into_iter() { hostnames_dest.push(hostname.to_string()); } diff --git a/shared/src/types.rs b/shared/src/types.rs index b112c45..4c7a88d 100644 --- a/shared/src/types.rs +++ b/shared/src/types.rs @@ -644,7 +644,7 @@ impl<'a> PeerDiff<'a> { .replace_allowed_ips() .add_allowed_ips(new_allowed_ips); changes.push(PeerChange::AllowedIPs { - old: old.map(|o| o.allowed_ips.clone()).unwrap_or_else(Vec::new), + old: old.map(|o| o.allowed_ips.clone()).unwrap_or_default(), new: new_allowed_ips.to_vec(), }); } @@ -921,7 +921,7 @@ mod tests { println!("{peer:?}"); println!("{:?}", info.config); - assert!(matches!(diff, Some(_))); + assert!(diff.is_some()); } #[test] diff --git a/wireguard-control/src/backends/kernel.rs b/wireguard-control/src/backends/kernel.rs index a0c7e6c..71837b1 100644 --- a/wireguard-control/src/backends/kernel.rs +++ b/wireguard-control/src/backends/kernel.rs @@ -366,8 +366,7 @@ pub fn get_by_name(name: &InterfaceName) -> Result { responses.len() ); - let nlas = responses.into_iter().fold(Ok(vec![]), |nlas_res, nlmsg| { - let mut nlas = nlas_res?; + let nlas = responses.into_iter().try_fold(vec![], |mut nlas, nlmsg| { let mut message = match nlmsg { NetlinkMessage { payload: NetlinkPayload::InnerMessage(message),