clippy: misc suggested clean up
diff --git a/src/crypto.rs b/src/crypto.rs
index 7227abf..b635e3c 100644
--- a/src/crypto.rs
+++ b/src/crypto.rs
@@ -24,13 +24,13 @@
use error::Error;
use shims;
-const HASH_ALG_PREFS: &'static [HashAlgorithm] = &[HashAlgorithm::Sha512, HashAlgorithm::Sha256];
+const HASH_ALG_PREFS: &[HashAlgorithm] = &[HashAlgorithm::Sha512, HashAlgorithm::Sha256];
/// 1.2.840.113549.1.1.1 rsaEncryption(PKCS #1)
-const RSA_SPKI_OID: &'static [u8] = &[0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01];
+const RSA_SPKI_OID: &[u8] = &[0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01];
/// 1.3.101.112 curveEd25519(EdDSA 25519 signature algorithm)
-const ED25519_SPKI_OID: &'static [u8] = &[0x2b, 0x65, 0x70];
+const ED25519_SPKI_OID: &[u8] = &[0x2b, 0x65, 0x70];
/// Given a map of hash algorithms and their values, get the prefered algorithm and the hash
/// calculated by it. Returns an `Err` if there is no match.
@@ -65,7 +65,7 @@
mut read: R,
hash_algs: &[HashAlgorithm],
) -> Result<(u64, HashMap<HashAlgorithm, HashValue>)> {
- if hash_algs.len() == 0 {
+ if hash_algs.is_empty() {
return Err(Error::IllegalArgument(
"Cannot provide empty set of hash algorithms".into(),
));
@@ -95,7 +95,7 @@
size += read_bytes as u64;
- for (_, context) in hashes.iter_mut() {
+ for context in hashes.values_mut() {
context.update(&buf[0..read_bytes]);
}
}
@@ -604,7 +604,7 @@
})?;
// for RSA / ed25519 this is null, so don't both parsing it
- let _ = derp::read_null(input)?;
+ derp::read_null(input)?;
Ok(typ)
})?;
let value = derp::bit_string_with_no_unused_bits(input)?;
diff --git a/src/interchange/mod.rs b/src/interchange/mod.rs
index f4f751c..9a98257 100644
--- a/src/interchange/mod.rs
+++ b/src/interchange/mod.rs
@@ -238,7 +238,7 @@
/// assert_eq!(out, br#"{"baz":"quux","foo":"bar"}"#);
/// ```
fn canonicalize(raw_data: &Self::RawData) -> Result<Vec<u8>> {
- cjson::canonicalize(raw_data).map_err(|e| Error::Opaque(e))
+ cjson::canonicalize(raw_data).map_err(Error::Opaque)
}
/// ```
diff --git a/src/metadata.rs b/src/metadata.rs
index 90a1c36..42778f9 100644
--- a/src/metadata.rs
+++ b/src/metadata.rs
@@ -102,7 +102,7 @@
return Err(Error::IllegalArgument("Path cannot be empty".into()));
}
- if path.starts_with("/") {
+ if path.starts_with('/') {
return Err(Error::IllegalArgument("Cannot start with '/'".into()));
}
@@ -426,7 +426,7 @@
where
I: IntoIterator<Item = &'a PublicKey>,
{
- if self.signatures.len() < 1 {
+ if self.signatures.is_empty() {
return Err(Error::VerificationFailure(
"The metadata was not signed with any authorized keys."
.into(),
@@ -447,7 +447,7 @@
let canonical_bytes = D::canonicalize(&self.signed)?;
let mut signatures_needed = threshold;
- for sig in self.signatures.iter() {
+ for sig in &self.signatures {
match authorized_keys.get(sig.key_id()) {
Some(ref pub_key) => {
match pub_key.verify(&canonical_bytes, &sig) {
diff --git a/src/tuf.rs b/src/tuf.rs
index 777ed5d..1227402 100644
--- a/src/tuf.rs
+++ b/src/tuf.rs
@@ -46,7 +46,7 @@
/// the related method `from_root_pinned`.
pub fn from_root(signed_root: &SignedMetadata<D, RootMetadata>) -> Result<Self> {
let root = D::deserialize::<RootMetadata>(signed_root.signed())?;
- let _ = signed_root.verify(
+ signed_root.verify(
root.root().threshold(),
root.keys().iter().filter_map(
|(k, v)| if root.root()
@@ -127,7 +127,7 @@
_ => (),
}
- let _ = signed_root.verify(
+ signed_root.verify(
root.root().threshold(),
root.keys().iter().filter_map(
|(k, v)| if root.root()
@@ -281,7 +281,7 @@
purge
};
- for role in purge.iter() {
+ for role in &purge {
let _ = self.delegations.remove(role);
}
}
@@ -389,13 +389,13 @@
return Ok(false);
}
- for (_, delegated_targets) in self.delegations.iter() {
+ for delegated_targets in self.delegations.values() {
let parent = match delegated_targets.delegations() {
Some(d) => d,
None => &targets_delegations,
};
- let delegation = match parent.roles().iter().filter(|r| r.role() == role).next() {
+ let delegation = match parent.roles().iter().find(|r| r.role() == role) {
Some(d) => d,
None => continue,
};
@@ -447,9 +447,8 @@
let _ = self.safe_snapshot_ref()?;
let targets = self.safe_targets_ref()?;
- match targets.targets().get(target_path) {
- Some(d) => return Ok(d.clone()),
- None => (),
+ if let Some(d) = targets.targets().get(target_path) {
+ return Ok(d.clone());
}
fn lookup<D: DataInterchange>(