From 5ef5de7f110bcbf8efdc4c3d3a77bc2e3afb67ca Mon Sep 17 00:00:00 2001 From: Michael Jeffrey Date: Thu, 9 Jan 2025 14:06:33 -0700 Subject: [PATCH] Update for new clippy lint about map_or https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or --- file_store/src/file_sink.rs | 2 +- iot_verifier/src/runner.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/file_store/src/file_sink.rs b/file_store/src/file_sink.rs index 771754e90..d2ee9d9ef 100644 --- a/file_store/src/file_sink.rs +++ b/file_store/src/file_sink.rs @@ -676,7 +676,7 @@ mod tests { .file_name() .to_str() .and_then(|file_name| FileInfo::from_str(file_name).ok()) - .map_or(false, |file_info| { + .is_some_and(|file_info| { FileType::from_str(&file_info.prefix).expect("entropy report prefix") == FileType::EntropyReport }) diff --git a/iot_verifier/src/runner.rs b/iot_verifier/src/runner.rs index 5b1092c8d..98d0f06f6 100644 --- a/iot_verifier/src/runner.rs +++ b/iot_verifier/src/runner.rs @@ -514,7 +514,7 @@ where .witness_updater .get_last_witness(&beacon_report.report.pub_key) .await?; - Ok(last_witness.map_or(false, |lw| { + Ok(last_witness.is_some_and(|lw| { beacon_report.received_timestamp - lw.timestamp < *RECIPROCITY_WINDOW })) } @@ -544,9 +544,8 @@ where ) -> anyhow::Result { let last_beacon_recip = LastBeaconReciprocity::get(&self.pool, &report.report.pub_key).await?; - Ok(last_beacon_recip.map_or(false, |lw| { - report.received_timestamp - lw.timestamp < *RECIPROCITY_WINDOW - })) + Ok(last_beacon_recip + .is_some_and(|lw| report.received_timestamp - lw.timestamp < *RECIPROCITY_WINDOW)) } }