Skip to content

Commit

Permalink
Fix clippy 1.72 and 1.73 lints (#289)
Browse files Browse the repository at this point in the history
Classic PR of mine.
  • Loading branch information
strohel authored Oct 16, 2023
1 parent 376ab64 commit b385ec6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hostsfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S: ToString>(&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());
}

Expand All @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}
Expand Down Expand Up @@ -921,7 +921,7 @@ mod tests {

println!("{peer:?}");
println!("{:?}", info.config);
assert!(matches!(diff, Some(_)));
assert!(diff.is_some());
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions wireguard-control/src/backends/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ pub fn get_by_name(name: &InterfaceName) -> Result<Device, io::Error> {
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),
Expand Down

0 comments on commit b385ec6

Please sign in to comment.