From 2760962530ae536aeda4074bb130b3b9799c143a Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 5 Dec 2024 16:15:37 +0000 Subject: [PATCH] Clippy fix --- src/core/presentation_submission.rs | 7 +++---- src/tests.rs | 6 ++---- tests/e2e.rs | 4 ++-- tests/jwt_vp.rs | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/core/presentation_submission.rs b/src/core/presentation_submission.rs index 3d77b60..b2329c8 100644 --- a/src/core/presentation_submission.rs +++ b/src/core/presentation_submission.rs @@ -136,7 +136,7 @@ pub struct MatchingInputs<'a, T> { pub by_descriptor: HashMap<&'a str, Vec>, } -impl<'a, T> MatchingInputs<'a, T> { +impl MatchingInputs<'_, T> { /// Validate the inputs against the presentation definition requirements. pub fn validate( &self, @@ -152,10 +152,9 @@ impl<'a, T> MatchingInputs<'a, T> { // By default each input descriptor must have at least one // associated input. for d in definition.input_descriptors() { - if !self + if self .by_descriptor - .get(d.id.as_str()) - .is_some_and(|i| !i.is_empty()) + .get(d.id.as_str()).is_none_or(|i| i.is_empty()) { return Err(SubmissionValidationError::MissingRequiredInput( d.id.clone(), diff --git a/src/tests.rs b/src/tests.rs index f3b6cd7..3ef6da2 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -184,11 +184,10 @@ fn test_input_descriptor_validation() -> Result<()> { let presentation_definition: PresentationDefinition = value .as_object_mut() - .map(|obj| { + .and_then(|obj| { obj.remove("presentation_definition") .map(serde_json::from_value) }) - .flatten() .expect("failed to parse presentation definition")?; let presentation_submission = include_str!( @@ -199,11 +198,10 @@ fn test_input_descriptor_validation() -> Result<()> { let presentation_submission: PresentationSubmission = value .as_object() - .map(|obj| { + .and_then(|obj| { obj.get("presentation_submission") .map(|v| serde_json::from_value(v.clone())) }) - .flatten() .expect("failed to parse presentation submission")?; // let descriptor_map = presentation_submission.descriptor_map(); diff --git a/tests/e2e.rs b/tests/e2e.rs index 1c3c9a0..e486f8e 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -54,14 +54,14 @@ async fn w3c_vc_did_client_direct_post() { ) .set_name("DID Key Identity Verification".into()) .set_purpose("Check whether your identity key has been verified.".into()) - .set_format((|| { + .set_format({ let mut map = ClaimFormatMap::new(); map.insert( ClaimFormatDesignation::JwtVcJson, ClaimFormatPayload::Alg(vec![Algorithm::ES256.to_string()]), ); map - })()), + }), ); let client_metadata = UntypedObject::default(); diff --git a/tests/jwt_vp.rs b/tests/jwt_vp.rs index 29e77b9..959cfcd 100644 --- a/tests/jwt_vp.rs +++ b/tests/jwt_vp.rs @@ -54,7 +54,7 @@ pub async fn create_test_verifiable_presentation() -> Result