parent
376ab64ed2
commit
b385ec6549
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue