Skip to content

Commit

Permalink
fix clippy warnings (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulmth committed Oct 9, 2023
1 parent 3e327fd commit 25e3442
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
36 changes: 14 additions & 22 deletions identity_did/src/did_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ impl Eq for RelativeDIDUrl {}

impl PartialOrd for RelativeDIDUrl {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
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
Expand All @@ -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
}
}

Expand Down Expand Up @@ -479,11 +475,7 @@ impl Eq for DIDUrl {}
impl PartialOrd for DIDUrl {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
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))
}
}

Expand Down
3 changes: 1 addition & 2 deletions identity_stronghold/src/stronghold_jwk_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions identity_stronghold/src/stronghold_key_id.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 25e3442

Please sign in to comment.