Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy 1.72 and 1.73 lints #289

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading