Merge pull request #311 from zxzxwu/rust

Fix Rust lints
This commit is contained in:
Gilles Boccon-Gibod
2023-10-06 13:37:47 -07:00
committed by GitHub
2 changed files with 3 additions and 8 deletions
+1 -3
View File
@@ -70,9 +70,7 @@ async fn main() -> PyResult<()> {
let mut seen_adv_cache = seen_adv_clone.lock().unwrap(); let mut seen_adv_cache = seen_adv_clone.lock().unwrap();
let expiry_duration = time::Duration::from_secs(cli.dedup_expiry_secs); let expiry_duration = time::Duration::from_secs(cli.dedup_expiry_secs);
let advs_from_addr = seen_adv_cache let advs_from_addr = seen_adv_cache.entry(addr_bytes).or_default();
.entry(addr_bytes)
.or_insert_with(collections::HashMap::new);
// we expect cache hits to be the norm, so we do a separate lookup to avoid cloning // we expect cache hits to be the norm, so we do a separate lookup to avoid cloning
// on every lookup with entry() // on every lookup with entry()
let show = if let Some(prev) = advs_from_addr.get_mut(&data_units) { let show = if let Some(prev) = advs_from_addr.get_mut(&data_units) {
+2 -5
View File
@@ -143,10 +143,7 @@ pub(crate) fn probe(verbose: bool) -> anyhow::Result<()> {
); );
if let Some(s) = serial { if let Some(s) = serial {
println!("{:26}{}", " Serial:".green(), s); println!("{:26}{}", " Serial:".green(), s);
device_serials_by_id device_serials_by_id.entry(device_id).or_default().insert(s);
.entry(device_id)
.or_insert(HashSet::new())
.insert(s);
} }
if let Some(m) = mfg { if let Some(m) = mfg {
println!("{:26}{}", " Manufacturer:".green(), m); println!("{:26}{}", " Manufacturer:".green(), m);
@@ -314,7 +311,7 @@ impl ClassInfo {
self.protocol, self.protocol,
self.protocol_name() self.protocol_name()
.map(|s| format!(" [{}]", s)) .map(|s| format!(" [{}]", s))
.unwrap_or_else(String::new) .unwrap_or_default()
) )
} }
} }