Fix clippy 1.72 and 1.73 lints (#289)

Classic PR of mine.
pull/295/head
Matěj Laitl 2023-10-16 09:22:53 +02:00 committed by GitHub
parent 376ab64ed2
commit b385ec6549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

View File

@ -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());
}
@ -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());
}

View File

@ -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]

View File

@ -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),