cargo clippy

This commit is contained in:
Pierre HUBERT 2022-04-03 17:40:10 +02:00
parent 886bae32c8
commit 48f4d4c6c5

View File

@ -1,3 +1,4 @@
use std::collections::hash_map::Entry;
use std::collections::HashMap; use std::collections::HashMap;
use std::net::IpAddr; use std::net::IpAddr;
@ -28,7 +29,7 @@ impl BruteForceActor {
pub fn clean_attempts(&mut self) { pub fn clean_attempts(&mut self) {
let keys = self.failed_attempts let keys = self.failed_attempts
.keys() .keys()
.map(|i| i.clone()) .map(|i| *i)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for ip in keys { for ip in keys {
@ -44,8 +45,8 @@ impl BruteForceActor {
} }
pub fn insert_failed_attempt(&mut self, ip: IpAddr) { pub fn insert_failed_attempt(&mut self, ip: IpAddr) {
if !self.failed_attempts.contains_key(&ip) { if let Entry::Vacant(e) = self.failed_attempts.entry(ip) {
self.failed_attempts.insert(ip, vec![time()]); e.insert(vec![time()]);
} else { } else {
self.failed_attempts.get_mut(&ip).unwrap().push(time()); self.failed_attempts.get_mut(&ip).unwrap().push(time());
} }