dialinfoclass refactor, cleaning up network class detection

This commit is contained in:
John Smith
2022-04-23 22:08:02 -04:00
parent 99dc4e16f9
commit 1156159748
12 changed files with 435 additions and 210 deletions

View File

@@ -168,3 +168,20 @@ pub fn listen_address_to_socket_addrs(listen_address: &str) -> Result<Vec<Socket
}
})
}
pub trait Dedup<T: PartialEq + Clone> {
fn remove_duplicates(&mut self);
}
impl<T: PartialEq + Clone> Dedup<T> for Vec<T> {
fn remove_duplicates(&mut self) {
let mut already_seen = Vec::new();
self.retain(|item| match already_seen.contains(item) {
true => false,
_ => {
already_seen.push(item.clone());
true
}
})
}
}