From 124e2f47c65545d7cd35f3299dc0f9a40b2b9926 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Mon, 9 Oct 2023 16:26:57 +0200 Subject: [PATCH] fix clippy warnings --- identity_did/src/did_url.rs | 36 ++++++++----------- .../src/stronghold_jwk_storage.rs | 3 +- identity_stronghold/src/stronghold_key_id.rs | 4 +-- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/identity_did/src/did_url.rs b/identity_did/src/did_url.rs index 7d24b543c3..60c7d6c84e 100644 --- a/identity_did/src/did_url.rs +++ b/identity_did/src/did_url.rs @@ -227,6 +227,12 @@ impl Eq for RelativeDIDUrl {} impl PartialOrd for RelativeDIDUrl { fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for RelativeDIDUrl { + fn cmp(&self, other: &Self) -> Ordering { // Compare path, query, then fragment in that order let path_cmp = self .path @@ -242,27 +248,17 @@ impl PartialOrd for RelativeDIDUrl { .cmp(other.query.as_deref().unwrap_or_default()); if query_cmp == Ordering::Equal { - return Some( - self - .fragment - .as_deref() - .unwrap_or_default() - .cmp(other.fragment.as_deref().unwrap_or_default()), - ); + return self + .fragment + .as_deref() + .unwrap_or_default() + .cmp(other.fragment.as_deref().unwrap_or_default()); } - return Some(query_cmp); + return query_cmp; } - Some(path_cmp) - } -} - -impl Ord for RelativeDIDUrl { - fn cmp(&self, other: &Self) -> Ordering { - self - .partial_cmp(other) - .expect("RelativeDIDUrl partial_cmp should always be Some") + path_cmp } } @@ -479,11 +475,7 @@ impl Eq for DIDUrl {} impl PartialOrd for DIDUrl { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - match self.did().partial_cmp(other.did()) { - None => None, - Some(Ordering::Equal) => self.url().partial_cmp(other.url()), - Some(ord) => Some(ord), - } + Some(self.cmp(other)) } } diff --git a/identity_stronghold/src/stronghold_jwk_storage.rs b/identity_stronghold/src/stronghold_jwk_storage.rs index 44f2d5117e..eb1b186f86 100644 --- a/identity_stronghold/src/stronghold_jwk_storage.rs +++ b/identity_stronghold/src/stronghold_jwk_storage.rs @@ -29,7 +29,6 @@ use iota_stronghold::Location; use iota_stronghold::Stronghold; use rand::distributions::DistString; use std::fmt::Display; -use std::ops::Deref; use std::str::FromStr; use std::sync::Arc; use tokio::sync::MutexGuard; @@ -308,7 +307,7 @@ async fn persist_changes( // Must be dropped since `write_stronghold_snapshot` needs to acquire the stronghold lock. drop(stronghold); - match secret_manager.as_secret_manager().deref() { + match secret_manager.as_secret_manager() { iota_sdk::client::secret::SecretManager::Stronghold(stronghold_manager) => { stronghold_manager .write_stronghold_snapshot(None) diff --git a/identity_stronghold/src/stronghold_key_id.rs b/identity_stronghold/src/stronghold_key_id.rs index dbfeb5865f..dcd3755cab 100644 --- a/identity_stronghold/src/stronghold_key_id.rs +++ b/identity_stronghold/src/stronghold_key_id.rs @@ -1,8 +1,6 @@ // Copyright 2020-2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::ops::Deref; - use crate::stronghold_jwk_storage::IDENTITY_CLIENT_PATH; use crate::StrongholdStorage; use async_trait::async_trait; @@ -102,7 +100,7 @@ async fn persist_changes( })?; // Must be dropped since `write_stronghold_snapshot` requires the stronghold instance. drop(stronghold); - match secret_manager.as_secret_manager().deref() { + match secret_manager.as_secret_manager() { iota_sdk::client::secret::SecretManager::Stronghold(stronghold_manager) => { stronghold_manager .write_stronghold_snapshot(None)