From 6a9e035d19414100f88eabd8ba3a7517a63c8a08 Mon Sep 17 00:00:00 2001 From: "Lucille L. Blumire" Date: Thu, 17 Apr 2025 16:06:24 +0100 Subject: [PATCH] refactor: combine equivalent match branches --- bin/verify-era-proof-attestation/src/core/types.rs | 6 +++--- .../src/processor/continuous_processor.rs | 5 +++-- .../src/processor/one_shot_processor.rs | 5 +++-- crates/teepot/src/quote/tcblevel.rs | 3 +-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/verify-era-proof-attestation/src/core/types.rs b/bin/verify-era-proof-attestation/src/core/types.rs index 0f8b7d7..e9d64b2 100644 --- a/bin/verify-era-proof-attestation/src/core/types.rs +++ b/bin/verify-era-proof-attestation/src/core/types.rs @@ -72,9 +72,9 @@ impl VerificationResult { verified_count, unverified_count, } => verified_count > unverified_count, - VerificationResult::Failure => false, - VerificationResult::Interrupted => false, - VerificationResult::NoProofsFound => false, + VerificationResult::Failure + | VerificationResult::Interrupted + | VerificationResult::NoProofsFound => false, } } } diff --git a/bin/verify-era-proof-attestation/src/processor/continuous_processor.rs b/bin/verify-era-proof-attestation/src/processor/continuous_processor.rs index 9796367..f9fb152 100644 --- a/bin/verify-era-proof-attestation/src/processor/continuous_processor.rs +++ b/bin/verify-era-proof-attestation/src/processor/continuous_processor.rs @@ -50,8 +50,9 @@ impl ContinuousProcessor { match self.batch_processor.process_batch(token, batch).await { Ok(result) => { match result { - VerificationResult::Success => success_count += 1, - VerificationResult::PartialSuccess { .. } => success_count += 1, + VerificationResult::Success | VerificationResult::PartialSuccess { .. } => { + success_count += 1; + } VerificationResult::Failure => failure_count += 1, VerificationResult::Interrupted => { results.push((current_batch, result)); diff --git a/bin/verify-era-proof-attestation/src/processor/one_shot_processor.rs b/bin/verify-era-proof-attestation/src/processor/one_shot_processor.rs index 1bd7d77..994724b 100644 --- a/bin/verify-era-proof-attestation/src/processor/one_shot_processor.rs +++ b/bin/verify-era-proof-attestation/src/processor/one_shot_processor.rs @@ -55,8 +55,9 @@ impl OneShotProcessor { let result = self.batch_processor.process_batch(token, batch).await?; match result { - VerificationResult::Success => success_count += 1, - VerificationResult::PartialSuccess { .. } => success_count += 1, + VerificationResult::Success | VerificationResult::PartialSuccess { .. } => { + success_count += 1; + } VerificationResult::Failure => failure_count += 1, VerificationResult::Interrupted => { results.push((batch_number, result)); diff --git a/crates/teepot/src/quote/tcblevel.rs b/crates/teepot/src/quote/tcblevel.rs index 19561a2..96cd5a0 100644 --- a/crates/teepot/src/quote/tcblevel.rs +++ b/crates/teepot/src/quote/tcblevel.rs @@ -38,8 +38,7 @@ impl FromStr for TcbLevel { fn from_str(s: &str) -> Result { match s.to_ascii_lowercase().as_str() { - "ok" => Ok(TcbLevel::Ok), - "uptodate" => Ok(TcbLevel::Ok), + "ok" | "uptodate" => Ok(TcbLevel::Ok), "configneeded" => Ok(TcbLevel::ConfigNeeded), "configandswhardeningneeded" => Ok(TcbLevel::ConfigAndSwHardeningNeeded), "swhardeningneeded" => Ok(TcbLevel::SwHardeningNeeded),