Merge pull request #132 from erickt/clippy

Clean up clippy suggestions
diff --git a/src/client.rs b/src/client.rs
index 7c1a8ca..b9933c0 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -85,12 +85,13 @@
 }
 
 /// A `PathTranslator` that does nothing.
-pub struct DefaultTranslator {}
+#[derive(Default)]
+pub struct DefaultTranslator;
 
 impl DefaultTranslator {
     /// Create a new `DefaultTranslator`.
     pub fn new() -> Self {
-        DefaultTranslator {}
+        DefaultTranslator
     }
 }
 
@@ -154,13 +155,13 @@
                 )
             })?;
 
-        let tuf = Tuf::from_root(root)?;
+        let tuf = Tuf::from_root(&root)?;
 
         Ok(Client {
-            tuf: tuf,
-            config: config,
-            local: local,
-            remote: remote,
+            tuf,
+            config,
+            local,
+            remote,
         })
     }
 
@@ -204,10 +205,10 @@
         let tuf = Tuf::from_root_pinned(root, trusted_root_keys)?;
 
         Ok(Client {
-            tuf: tuf,
-            config: config,
-            local: local,
-            remote: remote,
+            tuf,
+            config,
+            local,
+            remote,
         })
     }
 
@@ -301,13 +302,13 @@
                 config.min_bytes_per_second,
                 None,
             )?;
-            if !tuf.update_root(signed)? {
+            if !tuf.update_root(&signed)? {
                 error!("{}", err_msg);
                 return Err(Error::Programming(err_msg.into()));
             }
         }
 
-        if !tuf.update_root(latest_root)? {
+        if !tuf.update_root(&latest_root)? {
             error!("{}", err_msg);
             return Err(Error::Programming(err_msg.into()));
         }
@@ -328,7 +329,7 @@
             config.min_bytes_per_second,
             None,
         )?;
-        tuf.update_timestamp(ts)
+        tuf.update_timestamp(&ts)
     }
 
     /// Returns `true` if an update occurred and `false` otherwise.
@@ -363,7 +364,7 @@
             config.min_bytes_per_second,
             Some((alg, value.clone())),
         )?;
-        tuf.update_snapshot(snap)
+        tuf.update_snapshot(&snap)
     }
 
     /// Returns `true` if an update occurred and `false` otherwise.
@@ -407,7 +408,7 @@
             config.min_bytes_per_second,
             Some((alg, value.clone())),
         )?;
-        tuf.update_targets(targets)
+        tuf.update_targets(&targets)
     }
 
     /// Fetch a target from the remote repo and write it to the local repo.
@@ -478,9 +479,8 @@
                 }
             };
 
-            match targets.targets().get(target) {
-                Some(t) => return (default_terminate, Ok(t.clone())),
-                None => (),
+            if let Some(t) = targets.targets().get(target) {
+                return (default_terminate, Ok(t.clone()));
             }
 
             let delegations = match targets.delegations() {
@@ -544,7 +544,7 @@
                     }
                 };
 
-                match tuf.update_delegation(delegation.role(), signed_meta.clone()) {
+                match tuf.update_delegation(delegation.role(), &signed_meta) {
                     Ok(_) => {
                         match local.store_metadata(
                             &Role::Targets,
@@ -757,7 +757,7 @@
             max_timestamp_size: self.max_timestamp_size,
             min_bytes_per_second: self.min_bytes_per_second,
             max_delegation_depth: self.max_delegation_depth,
-            path_translator: path_translator,
+            path_translator,
         }
     }
 }
diff --git a/src/crypto.rs b/src/crypto.rs
index c5598d3..b893b96 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(),
         ));
@@ -74,10 +74,10 @@
     let mut size = 0;
     let mut hashes = HashMap::new();
     for alg in hash_algs {
-        let context = match alg {
-            &HashAlgorithm::Sha256 => digest::Context::new(&SHA256),
-            &HashAlgorithm::Sha512 => digest::Context::new(&SHA512),
-            &HashAlgorithm::Unknown(ref s) => return Err(Error::IllegalArgument(
+        let context = match *alg {
+            HashAlgorithm::Sha256 => digest::Context::new(&SHA256),
+            HashAlgorithm::Sha512 => digest::Context::new(&SHA512),
+            HashAlgorithm::Unknown(ref s) => return Err(Error::IllegalArgument(
                 format!("Unknown hash algorithm: {}", s)
             )),
         };
@@ -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]);
                 }
             }
@@ -278,10 +278,10 @@
     }
 
     fn as_oid(&self) -> Result<&'static [u8]> {
-        match self {
-            &KeyType::Rsa => Ok(RSA_SPKI_OID),
-            &KeyType::Ed25519 => Ok(ED25519_SPKI_OID),
-            &KeyType::Unknown(ref s) => Err(Error::UnknownKeyType(s.clone())),
+        match *self {
+            KeyType::Rsa => Ok(RSA_SPKI_OID),
+            KeyType::Ed25519 => Ok(ED25519_SPKI_OID),
+            KeyType::Unknown(ref s) => Err(Error::UnknownKeyType(s.clone())),
         }
     }
 }
@@ -300,10 +300,10 @@
 
 impl ToString for KeyType {
     fn to_string(&self) -> String {
-        match self {
-            &KeyType::Ed25519 => "ed25519".to_string(),
-            &KeyType::Rsa => "rsa".to_string(),
-            &KeyType::Unknown(ref s) => s.to_string(),
+        match *self {
+            KeyType::Ed25519 => "ed25519".to_string(),
+            KeyType::Rsa => "rsa".to_string(),
+            KeyType::Unknown(ref s) => s.to_string(),
         }
     }
 }
@@ -333,9 +333,9 @@
 
 impl Debug for PrivateKeyType {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let s = match self {
-            &PrivateKeyType::Ed25519(_) => "ed25519",
-            &PrivateKeyType::Rsa(_) => "rsa",
+        let s = match *self {
+            PrivateKeyType::Ed25519(_) => "ed25519",
+            PrivateKeyType::Rsa(_) => "rsa",
         };
         write!(f, "PrivateKeyType {{ \"{}\" }}", s)
     }
@@ -445,19 +445,16 @@
         let private = PrivateKeyType::Ed25519(key);
 
         Ok(PrivateKey {
-            private: private,
-            public: public,
+            private,
+            public,
         })
     }
 
     fn rsa_from_pkcs8(der_key: &[u8], scheme: SignatureScheme) -> Result<Self> {
-        match &scheme {
-            &SignatureScheme::Ed25519 => {
-                return Err(Error::IllegalArgument(
-                    "RSA keys do not support the Ed25519 signing scheme".into(),
-                ))
-            }
-            _ => (),
+        if let SignatureScheme::Ed25519 = scheme {
+            return Err(Error::IllegalArgument(
+                "RSA keys do not support the Ed25519 signing scheme".into(),
+            ));
         }
 
         let key = RSAKeyPair::from_pkcs8(Input::from(der_key)).map_err(|_| {
@@ -475,15 +472,15 @@
 
         let public = PublicKey {
             typ: KeyType::Rsa,
-            scheme: scheme,
+            scheme,
             key_id: calculate_key_id(&write_spki(&pub_key, &KeyType::Rsa)?),
             value: PublicKeyValue(pub_key),
         };
         let private = PrivateKeyType::Rsa(Arc::new(key));
 
         Ok(PrivateKey {
-            private: private,
-            public: public,
+            private,
+            public,
         })
     }
 
@@ -524,7 +521,7 @@
 
         Ok(Signature {
             key_id: self.key_id().clone(),
-            value: value,
+            value,
         })
     }
 
@@ -607,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)?;
@@ -617,9 +614,9 @@
 
         let key_id = calculate_key_id(der_bytes);
         Ok(PublicKey {
-            typ: typ,
-            key_id: key_id,
-            scheme: scheme,
+            typ,
+            key_id,
+            scheme,
             value: PublicKeyValue(value),
         })
     }
@@ -648,11 +645,11 @@
 
     /// Use this key to verify a message with a signature.
     pub fn verify(&self, msg: &[u8], sig: &Signature) -> Result<()> {
-        let alg: &ring::signature::VerificationAlgorithm = match &self.scheme {
-            &SignatureScheme::Ed25519 => &ED25519,
-            &SignatureScheme::RsaSsaPssSha256 => &RSA_PSS_2048_8192_SHA256,
-            &SignatureScheme::RsaSsaPssSha512 => &RSA_PSS_2048_8192_SHA512,
-            &SignatureScheme::Unknown(ref s) => return Err(Error::IllegalArgument(
+        let alg: &ring::signature::VerificationAlgorithm = match self.scheme {
+            SignatureScheme::Ed25519 => &ED25519,
+            SignatureScheme::RsaSsaPssSha256 => &RSA_PSS_2048_8192_SHA256,
+            SignatureScheme::RsaSsaPssSha512 => &RSA_PSS_2048_8192_SHA512,
+            SignatureScheme::Unknown(ref s) => return Err(Error::IllegalArgument(
                 format!("Unknown signature scheme: {}", s)
             )),
         };
diff --git a/src/error.rs b/src/error.rs
index 11dddbf..4cfc435 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -78,7 +78,7 @@
 
 impl Error {
     /// Helper to include the path that causd the error for FS I/O errors.
-    pub fn from_io(err: io::Error, path: &Path) -> Error {
+    pub fn from_io(err: &io::Error, path: &Path) -> Error {
         Error::Opaque(format!("Path {:?} : {:?}", path, err))
     }
 }
diff --git a/src/interchange/cjson.rs b/src/interchange/cjson.rs
index 2071fb6..5f2d947 100644
--- a/src/interchange/cjson.rs
+++ b/src/interchange/cjson.rs
@@ -20,27 +20,37 @@
 
 impl Value {
     fn write(&self, mut buf: &mut Vec<u8>) -> Result<(), String> {
-        match self {
-            &Value::Null => Ok(buf.extend(b"null")),
-            &Value::Bool(true) => Ok(buf.extend(b"true")),
-            &Value::Bool(false) => Ok(buf.extend(b"false")),
-            &Value::Number(Number::I64(n)) => {
+        match *self {
+            Value::Null => {
+                buf.extend(b"null");
+                Ok(())
+            }
+            Value::Bool(true) => {
+                buf.extend(b"true");
+                Ok(())
+            }
+            Value::Bool(false) => {
+                buf.extend(b"false");
+                Ok(())
+            }
+            Value::Number(Number::I64(n)) => {
                 itoa::write(buf, n).map(|_| ()).map_err(|err| {
                     format!("Write error: {}", err)
                 })
             }
-            &Value::Number(Number::U64(n)) => {
+            Value::Number(Number::U64(n)) => {
                 itoa::write(buf, n).map(|_| ()).map_err(|err| {
                     format!("Write error: {}", err)
                 })
             }
-            &Value::String(ref s) => {
+            Value::String(ref s) => {
                 // this mess is abusing serde_json to get json escaping
                 let s = json::Value::String(s.clone());
                 let s = json::to_string(&s).map_err(|e| format!("{:?}", e))?;
-                Ok(buf.extend(s.as_bytes()))
+                buf.extend(s.as_bytes());
+                Ok(())
             }
-            &Value::Array(ref arr) => {
+            Value::Array(ref arr) => {
                 buf.push(b'[');
                 let mut first = true;
                 for a in arr.iter() {
@@ -50,9 +60,10 @@
                     a.write(&mut buf)?;
                     first = false;
                 }
-                Ok(buf.push(b']'))
+                buf.push(b']');
+                Ok(())
             }
-            &Value::Object(ref obj) => {
+            Value::Object(ref obj) => {
                 buf.push(b'{');
                 let mut first = true;
                 for (k, v) in obj.iter() {
@@ -69,7 +80,8 @@
                     buf.push(b':');
                     v.write(&mut buf)?;
                 }
-                Ok(buf.push(b'}'))
+                buf.push(b'}');
+                Ok(())
             }
         }
     }
@@ -81,31 +93,31 @@
 }
 
 fn convert(jsn: &json::Value) -> Result<Value, String> {
-    match jsn {
-        &json::Value::Null => Ok(Value::Null),
-        &json::Value::Bool(b) => Ok(Value::Bool(b)),
-        &json::Value::Number(ref n) => {
+    match *jsn {
+        json::Value::Null => Ok(Value::Null),
+        json::Value::Bool(b) => Ok(Value::Bool(b)),
+        json::Value::Number(ref n) => {
             n.as_i64()
                 .map(Number::I64)
-                .or(n.as_u64().map(Number::U64))
+                .or_else(|| n.as_u64().map(Number::U64))
                 .map(Value::Number)
                 .ok_or_else(|| String::from("only i64 and u64 are supported"))
         }
-        &json::Value::Array(ref arr) => {
+        json::Value::Array(ref arr) => {
             let mut out = Vec::new();
             for res in arr.iter().map(|v| convert(v)) {
                 out.push(res?)
             }
             Ok(Value::Array(out))
         }
-        &json::Value::Object(ref obj) => {
+        json::Value::Object(ref obj) => {
             let mut out = BTreeMap::new();
             for (k, v) in obj.iter() {
                 let _ = out.insert(k.clone(), convert(v)?);
             }
             Ok(Value::Object(out))
         }
-        &json::Value::String(ref s) => Ok(Value::String(s.clone())),
+        json::Value::String(ref s) => Ok(Value::String(s.clone())),
     }
 }
 
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/lib.rs b/src/lib.rs
index 42c4237..aa65a60 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -103,6 +103,17 @@
 
 #![deny(missing_docs)]
 
+#![cfg_attr(
+    feature = "cargo-clippy",
+    allow(
+        collapsible_if,
+        implicit_hasher,
+        new_ret_no_self,
+        op_ref,
+        too_many_arguments,
+    )
+)]
+
 extern crate chrono;
 extern crate data_encoding;
 extern crate derp;
diff --git a/src/metadata.rs b/src/metadata.rs
index 7c349d0..c9f2bfb 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()));
     }
 
@@ -168,12 +168,12 @@
     /// assert!(!Role::Root.fuzzy_matches_path(&MetadataPath::new("wat".into()).unwrap()));
     /// ```
     pub fn fuzzy_matches_path(&self, path: &MetadataPath) -> bool {
-        match self {
-            &Role::Root if &path.0 == "root" => true,
-            &Role::Snapshot if &path.0 == "snapshot" => true,
-            &Role::Timestamp if &path.0 == "timestamp" => true,
-            &Role::Targets if &path.0 == "targets" => true,
-            &Role::Targets if !&["root", "snapshot", "targets"].contains(&path.0.as_str()) => true,
+        match *self {
+            Role::Root if &path.0 == "root" => true,
+            Role::Snapshot if &path.0 == "snapshot" => true,
+            Role::Timestamp if &path.0 == "timestamp" => true,
+            Role::Targets if &path.0 == "targets" => true,
+            Role::Targets if !&["root", "snapshot", "targets"].contains(&path.0.as_str()) => true,
             _ => false,
         }
     }
@@ -181,11 +181,11 @@
 
 impl Display for Role {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match self {
-            &Role::Root => write!(f, "root"),
-            &Role::Snapshot => write!(f, "snapshot"),
-            &Role::Targets => write!(f, "targets"),
-            &Role::Timestamp => write!(f, "timestamp"),
+        match *self {
+            Role::Root => write!(f, "root"),
+            Role::Snapshot => write!(f, "snapshot"),
+            Role::Targets => write!(f, "targets"),
+            Role::Timestamp => write!(f, "timestamp"),
         }
     }
 }
@@ -204,10 +204,10 @@
 impl MetadataVersion {
     /// Converts this struct into the string used for addressing metadata.
     pub fn prefix(&self) -> String {
-        match self {
-            &MetadataVersion::None => String::new(),
-            &MetadataVersion::Number(ref x) => format!("{}.", x),
-            &MetadataVersion::Hash(ref v) => format!("{}.", v),
+        match *self {
+            MetadataVersion::None => String::new(),
+            MetadataVersion::Number(ref x) => format!("{}.", x),
+            MetadataVersion::Hash(ref v) => format!("{}.", v),
         }
     }
 }
@@ -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) {
@@ -524,14 +524,14 @@
         }
 
         Ok(RootMetadata {
-            version: version,
-            expires: expires,
-            consistent_snapshot: consistent_snapshot,
-            keys: keys,
-            root: root,
-            snapshot: snapshot,
-            targets: targets,
-            timestamp: timestamp,
+            version,
+            expires,
+            consistent_snapshot,
+            keys,
+            root,
+            snapshot,
+            targets,
+            timestamp,
         })
     }
 
@@ -624,7 +624,7 @@
             ));
         }
 
-        if (key_ids.len() as u64) < (threshold as u64) {
+        if (key_ids.len() as u64) < u64::from(threshold) {
             return Err(Error::IllegalArgument(format!(
                 "Cannot have a threshold greater than the number of associated key IDs. {} vs. {}",
                 threshold,
@@ -633,8 +633,8 @@
         }
 
         Ok(RoleDefinition {
-            threshold: threshold,
-            key_ids: key_ids,
+            threshold,
+            key_ids,
         })
     }
 
@@ -786,9 +786,9 @@
         }
 
         Ok(TimestampMetadata {
-            version: version,
-            expires: expires,
-            snapshot: snapshot,
+            version,
+            expires,
+            snapshot,
         })
     }
 
@@ -864,9 +864,9 @@
         }
 
         Ok(MetadataDescription {
-            version: version,
+            version,
             size: size as usize,
-            hashes: hashes,
+            hashes,
         })
     }
 
@@ -890,9 +890,9 @@
         }
 
         Ok(MetadataDescription {
-            version: version,
-            size: size,
-            hashes: hashes,
+            version,
+            size,
+            hashes,
         })
     }
 
@@ -944,9 +944,9 @@
         }
 
         Ok(SnapshotMetadata {
-            version: version,
-            expires: expires,
-            meta: meta,
+            version,
+            expires,
+            meta,
         })
     }
 
@@ -1152,8 +1152,8 @@
         }
 
         Ok(TargetDescription {
-            size: size,
-            hashes: hashes,
+            size,
+            hashes,
         })
     }
 
@@ -1193,8 +1193,8 @@
     {
         let (size, hashes) = crypto::calculate_hashes(read, hash_algs)?;
         Ok(TargetDescription {
-            size: size,
-            hashes: hashes,
+            size,
+            hashes,
         })
     }
 
@@ -1243,10 +1243,10 @@
         }
 
         Ok(TargetsMetadata {
-            version: version,
-            expires: expires,
-            targets: targets,
-            delegations: delegations,
+            version,
+            expires,
+            targets,
+            delegations,
         })
     }
 
@@ -1308,7 +1308,7 @@
     // TODO check all keys are used
     // TODO check all roles have their ID in the set of keys
     /// Create a new `Delegations` wrapper from the given set of trusted keys and roles.
-    pub fn new(keys: HashSet<PublicKey>, roles: Vec<Delegation>) -> Result<Self> {
+    pub fn new(keys: &HashSet<PublicKey>, roles: Vec<Delegation>) -> Result<Self> {
         if keys.is_empty() {
             return Err(Error::IllegalArgument("Keys cannot be empty.".into()));
         }
@@ -1334,7 +1334,7 @@
                 .cloned()
                 .map(|k| (k.key_id().clone(), k))
                 .collect(),
-            roles: roles,
+            roles,
         })
     }
 
@@ -1399,18 +1399,18 @@
             return Err(Error::IllegalArgument("Cannot have threshold < 1".into()));
         }
 
-        if (key_ids.len() as u64) < (threshold as u64) {
+        if (key_ids.len() as u64) < u64::from(threshold) {
             return Err(Error::IllegalArgument(
                 "Cannot have threshold less than number of keys".into(),
             ));
         }
 
         Ok(Delegation {
-            role: role,
-            terminating: terminating,
-            threshold: threshold,
-            key_ids: key_ids,
-            paths: paths,
+            role,
+            terminating,
+            threshold,
+            key_ids,
+            paths,
         })
     }
 
@@ -1787,7 +1787,7 @@
     fn serde_targets_with_delegations_metadata() {
         let key = PrivateKey::from_pkcs8(ED25519_1_PK8, SignatureScheme::Ed25519).unwrap();
         let delegations = Delegations::new(
-            hashset![key.public().clone()],
+            &hashset![key.public().clone()],
             vec![Delegation::new(
                 MetadataPath::new("foo/bar".into()).unwrap(),
                 false,
@@ -1988,7 +1988,7 @@
             .public()
             .clone();
         let delegations = Delegations::new(
-            hashset![key.clone()],
+            &hashset![key.clone()],
             vec![Delegation::new(
                 MetadataPath::new("foo".into()).unwrap(),
                 false,
@@ -2328,7 +2328,7 @@
             .public()
             .clone();
         let delegations = Delegations::new(
-            hashset!(key.clone()),
+            &hashset!(key.clone()),
             vec![Delegation::new(
                 MetadataPath::new("foo".into()).unwrap(),
                 false,
diff --git a/src/repository.rs b/src/repository.rs
index 6543fb9..e0d36a8 100644
--- a/src/repository.rs
+++ b/src/repository.rs
@@ -110,7 +110,7 @@
     /// Create a new repository on the local file system.
     pub fn new(local_path: PathBuf) -> Self {
         FileSystemRepository {
-            local_path: local_path,
+            local_path,
             interchange: PhantomData,
         }
     }
@@ -285,10 +285,10 @@
         };
 
         HttpRepository {
-            url: url,
-            client: client,
-            user_agent: user_agent,
-            metadata_prefix: metadata_prefix,
+            url,
+            client,
+            user_agent,
+            metadata_prefix,
             interchange: PhantomData,
         }
     }
@@ -302,7 +302,7 @@
             let mut segments = url.path_segments_mut().map_err(|_| {
                 Error::IllegalArgument(format!("URL was 'cannot-be-a-base': {:?}", self.url))
             })?;
-            if let &Some(ref prefix) = prefix {
+            if let Some(ref prefix) = prefix {
                 segments.extend(prefix);
             }
             segments.extend(components);
@@ -431,6 +431,15 @@
     }
 }
 
+impl<D> Default for EphemeralRepository<D>
+where
+    D: DataInterchange,
+{
+    fn default() -> Self {
+        EphemeralRepository::new()
+    }
+}
+
 impl<D> Repository<D> for EphemeralRepository<D>
 where
     D: DataInterchange,
diff --git a/src/shims.rs b/src/shims.rs
index e252aec..cb7197a 100644
--- a/src/shims.rs
+++ b/src/shims.rs
@@ -53,7 +53,7 @@
             version: meta.version(),
             expires: format_datetime(&meta.expires()),
             consistent_snapshot: meta.consistent_snapshot(),
-            keys: keys,
+            keys,
             root: meta.root().clone(),
             snapshot: meta.snapshot().clone(),
             targets: meta.targets().clone(),
@@ -98,7 +98,7 @@
 
         Ok(RoleDefinition {
             threshold: role.threshold(),
-            key_ids: key_ids,
+            key_ids,
         })
     }
 
@@ -244,8 +244,8 @@
         public_key_bytes: &[u8],
     ) -> Self {
         PublicKey {
-            typ: typ,
-            scheme: scheme,
+            typ,
+            scheme,
             public_key: BASE64URL.encode(public_key_bytes),
         }
     }
@@ -289,8 +289,8 @@
             role: meta.role().clone(),
             terminating: meta.terminating(),
             threshold: meta.threshold(),
-            key_ids: key_ids,
-            paths: paths,
+            key_ids,
+            paths,
         }
     }
 
@@ -332,7 +332,7 @@
         keys.sort();
 
         Delegations {
-            keys: keys,
+            keys,
             roles: delegations.roles().clone(),
         }
     }
@@ -343,7 +343,7 @@
         if keys.len() != keys_len {
             return Err(Error::Encoding("Cannot have duplicate keys".into()));
         }
-        metadata::Delegations::new(keys, self.roles)
+        metadata::Delegations::new(&keys, self.roles)
     }
 }
 
diff --git a/src/tuf.rs b/src/tuf.rs
index eea3eec..1227402 100644
--- a/src/tuf.rs
+++ b/src/tuf.rs
@@ -37,16 +37,16 @@
         signed_root.signatures_mut().retain(|s| {
             root_key_ids.contains(s.key_id())
         });
-        Self::from_root(signed_root)
+        Self::from_root(&signed_root)
     }
 
     /// Create a new `TUF` struct from a piece of metadata that is assumed to be trusted.
     ///
     /// **WARNING**: This is trust-on-first-use (TOFU) and offers weaker security guarantees than
     /// the related method `from_root_pinned`.
-    pub fn from_root(signed_root: SignedMetadata<D, RootMetadata>) -> Result<Self> {
+    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()
@@ -60,7 +60,7 @@
             ),
         )?;
         Ok(Tuf {
-            root: root,
+            root,
             snapshot: None,
             targets: None,
             timestamp: None,
@@ -95,7 +95,7 @@
     }
 
     /// Verify and update the root metadata.
-    pub fn update_root(&mut self, signed_root: SignedMetadata<D, RootMetadata>) -> Result<bool> {
+    pub fn update_root(&mut self, signed_root: &SignedMetadata<D, RootMetadata>) -> Result<bool> {
         signed_root.verify(
             self.root.root().threshold(),
             self.root.keys().iter().filter_map(|(k, v)| {
@@ -127,7 +127,7 @@
             _ => (),
         }
 
-        let _ = signed_root.verify(
+        signed_root.verify(
             root.root().threshold(),
             root.keys().iter().filter_map(
                 |(k, v)| if root.root()
@@ -150,7 +150,7 @@
     /// Verify and update the timestamp metadata.
     pub fn update_timestamp(
         &mut self,
-        signed_timestamp: SignedMetadata<D, TimestampMetadata>,
+        signed_timestamp: &SignedMetadata<D, TimestampMetadata>,
     ) -> Result<bool> {
         signed_timestamp.verify(
             self.root.timestamp().threshold(),
@@ -196,7 +196,7 @@
     /// Verify and update the snapshot metadata.
     pub fn update_snapshot(
         &mut self,
-        signed_snapshot: SignedMetadata<D, SnapshotMetadata>,
+        signed_snapshot: &SignedMetadata<D, SnapshotMetadata>,
     ) -> Result<bool> {
         let snapshot = {
             let root = self.safe_root_ref()?;
@@ -281,7 +281,7 @@
             purge
         };
 
-        for role in purge.iter() {
+        for role in &purge {
             let _ = self.delegations.remove(role);
         }
     }
@@ -289,7 +289,7 @@
     /// Verify and update the targets metadata.
     pub fn update_targets(
         &mut self,
-        signed_targets: SignedMetadata<D, TargetsMetadata>,
+        signed_targets: &SignedMetadata<D, TargetsMetadata>,
     ) -> Result<bool> {
         let targets = {
             let root = self.safe_root_ref()?;
@@ -351,7 +351,7 @@
     pub fn update_delegation(
         &mut self,
         role: &MetadataPath,
-        signed: SignedMetadata<D, TargetsMetadata>,
+        signed: &SignedMetadata<D, TargetsMetadata>,
     ) -> Result<bool> {
         let delegation = {
             let _ = self.safe_root_ref()?;
@@ -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>(
@@ -458,7 +457,7 @@
             current_depth: u32,
             target_path: &VirtualTargetPath,
             delegations: &Delegations,
-            parents: Vec<HashSet<VirtualTargetPath>>,
+            parents: &[HashSet<VirtualTargetPath>],
             visited: &mut HashSet<MetadataPath>,
         ) -> (bool, Option<TargetDescription>) {
             for delegation in delegations.roles() {
@@ -467,7 +466,7 @@
                 }
                 let _ = visited.insert(delegation.role().clone());
 
-                let mut new_parents = parents.clone();
+                let mut new_parents = parents.to_owned();
                 new_parents.push(delegation.paths().clone());
 
                 if current_depth > 0 && !target_path.matches_chain(&parents) {
@@ -496,7 +495,7 @@
                         current_depth + 1,
                         target_path,
                         d,
-                        new_parents,
+                        &new_parents,
                         visited,
                     );
                     if term {
@@ -512,7 +511,7 @@
         match targets.delegations() {
             Some(d) => {
                 let mut visited = HashSet::new();
-                lookup(self, false, 0, target_path, d, vec![], &mut visited)
+                lookup(self, false, 0, target_path, d, &[], &mut visited)
                     .1
                     .ok_or_else(|| Error::TargetUnavailable)
             }
@@ -535,37 +534,37 @@
     }
 
     fn safe_snapshot_ref(&self) -> Result<&SnapshotMetadata> {
-        match &self.snapshot {
-            &Some(ref snapshot) => {
+        match self.snapshot {
+            Some(ref snapshot) => {
                 if snapshot.expires() <= &Utc::now() {
                     return Err(Error::ExpiredMetadata(Role::Snapshot));
                 }
                 Ok(snapshot)
             }
-            &None => Err(Error::MissingMetadata(Role::Snapshot)),
+            None => Err(Error::MissingMetadata(Role::Snapshot)),
         }
     }
 
     fn safe_targets_ref(&self) -> Result<&TargetsMetadata> {
-        match &self.targets {
-            &Some(ref targets) => {
+        match self.targets {
+            Some(ref targets) => {
                 if targets.expires() <= &Utc::now() {
                     return Err(Error::ExpiredMetadata(Role::Targets));
                 }
                 Ok(targets)
             }
-            &None => Err(Error::MissingMetadata(Role::Targets)),
+            None => Err(Error::MissingMetadata(Role::Targets)),
         }
     }
     fn safe_timestamp_ref(&self) -> Result<&TimestampMetadata> {
-        match &self.timestamp {
-            &Some(ref timestamp) => {
+        match self.timestamp {
+            Some(ref timestamp) => {
                 if timestamp.expires() <= &Utc::now() {
                     return Err(Error::ExpiredMetadata(Role::Timestamp));
                 }
                 Ok(timestamp)
             }
-            &None => Err(Error::MissingMetadata(Role::Timestamp)),
+            None => Err(Error::MissingMetadata(Role::Timestamp)),
         }
     }
 }
@@ -645,7 +644,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let root = RootMetadata::new(
             2,
@@ -663,10 +662,10 @@
         // add the original key's signature to make it cross signed
         root.add_signature(&KEYS[0]).unwrap();
 
-        assert_eq!(tuf.update_root(root.clone()), Ok(true));
+        assert_eq!(tuf.update_root(&root), Ok(true));
 
         // second update should do nothing
-        assert_eq!(tuf.update_root(root), Ok(false));
+        assert_eq!(tuf.update_root(&root), Ok(false));
     }
 
     #[test]
@@ -684,7 +683,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let root = RootMetadata::new(
             2,
@@ -700,7 +699,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[1])
             .unwrap();
 
-        assert!(tuf.update_root(root).is_err());
+        assert!(tuf.update_root(&root).is_err());
     }
 
     #[test]
@@ -718,7 +717,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -729,10 +728,10 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[1]).unwrap();
 
-        assert_eq!(tuf.update_timestamp(timestamp.clone()), Ok(true));
+        assert_eq!(tuf.update_timestamp(&timestamp), Ok(true));
 
         // second update should do nothing
-        assert_eq!(tuf.update_timestamp(timestamp), Ok(false))
+        assert_eq!(tuf.update_timestamp(&timestamp), Ok(false))
     }
 
     #[test]
@@ -750,7 +749,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -763,7 +762,7 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[0]).unwrap();
 
-        assert!(tuf.update_timestamp(timestamp).is_err())
+        assert!(tuf.update_timestamp(&timestamp).is_err())
     }
 
     #[test]
@@ -785,7 +784,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -796,17 +795,17 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[2]).unwrap();
 
-        tuf.update_timestamp(timestamp).unwrap();
+        tuf.update_timestamp(&timestamp).unwrap();
 
         let snapshot = SnapshotMetadata::new(1, Utc.ymd(2038, 1, 1).and_hms(0, 0, 0), hashmap!())
             .unwrap();
         let snapshot: SignedMetadata<Json, SnapshotMetadata> =
             SignedMetadata::new(&snapshot, &KEYS[1]).unwrap();
 
-        assert_eq!(tuf.update_snapshot(snapshot.clone()), Ok(true));
+        assert_eq!(tuf.update_snapshot(&snapshot), Ok(true));
 
         // second update should do nothing
-        assert_eq!(tuf.update_snapshot(snapshot), Ok(false));
+        assert_eq!(tuf.update_snapshot(&snapshot), Ok(false));
     }
 
     #[test]
@@ -828,7 +827,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -839,14 +838,14 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[2]).unwrap();
 
-        tuf.update_timestamp(timestamp).unwrap();
+        tuf.update_timestamp(&timestamp).unwrap();
 
         let snapshot = SnapshotMetadata::new(1, Utc.ymd(2038, 1, 1).and_hms(0, 0, 0), hashmap!())
             .unwrap();
         let snapshot: SignedMetadata<Json, SnapshotMetadata> =
             SignedMetadata::new(&snapshot, &KEYS[2]).unwrap();
 
-        assert!(tuf.update_snapshot(snapshot.clone()).is_err());
+        assert!(tuf.update_snapshot(&snapshot).is_err());
     }
 
     #[test]
@@ -868,7 +867,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -879,14 +878,14 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[2]).unwrap();
 
-        tuf.update_timestamp(timestamp).unwrap();
+        tuf.update_timestamp(&timestamp).unwrap();
 
         let snapshot = SnapshotMetadata::new(1, Utc.ymd(2038, 1, 1).and_hms(0, 0, 0), hashmap!())
             .unwrap();
         let snapshot: SignedMetadata<Json, SnapshotMetadata> =
             SignedMetadata::new(&snapshot, &KEYS[1]).unwrap();
 
-        assert!(tuf.update_snapshot(snapshot).is_err());
+        assert!(tuf.update_snapshot(&snapshot).is_err());
     }
 
     #[test]
@@ -909,7 +908,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -920,7 +919,7 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[3]).unwrap();
 
-        tuf.update_timestamp(timestamp).unwrap();
+        tuf.update_timestamp(&timestamp).unwrap();
 
         let meta_map =
             hashmap!(
@@ -932,7 +931,7 @@
         let snapshot: SignedMetadata<Json, SnapshotMetadata> =
             SignedMetadata::new(&snapshot, &KEYS[1]).unwrap();
 
-        tuf.update_snapshot(snapshot).unwrap();
+        tuf.update_snapshot(&snapshot).unwrap();
 
         let targets =
             TargetsMetadata::new(1, Utc.ymd(2038, 1, 1).and_hms(0, 0, 0), hashmap!(), None)
@@ -940,10 +939,10 @@
         let targets: SignedMetadata<Json, TargetsMetadata> =
             SignedMetadata::new(&targets, &KEYS[2]).unwrap();
 
-        assert_eq!(tuf.update_targets(targets.clone()), Ok(true));
+        assert_eq!(tuf.update_targets(&targets), Ok(true));
 
         // second update should do nothing
-        assert_eq!(tuf.update_targets(targets), Ok(false));
+        assert_eq!(tuf.update_targets(&targets), Ok(false));
     }
 
     #[test]
@@ -966,7 +965,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -977,7 +976,7 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[3]).unwrap();
 
-        tuf.update_timestamp(timestamp).unwrap();
+        tuf.update_timestamp(&timestamp).unwrap();
 
         let meta_map =
             hashmap!(
@@ -989,7 +988,7 @@
         let snapshot: SignedMetadata<Json, SnapshotMetadata> =
             SignedMetadata::new(&snapshot, &KEYS[1]).unwrap();
 
-        tuf.update_snapshot(snapshot).unwrap();
+        tuf.update_snapshot(&snapshot).unwrap();
 
         let targets =
             TargetsMetadata::new(1, Utc.ymd(2038, 1, 1).and_hms(0, 0, 0), hashmap!(), None)
@@ -997,7 +996,7 @@
         let targets: SignedMetadata<Json, TargetsMetadata> =
             SignedMetadata::new(&targets, &KEYS[3]).unwrap();
 
-        assert!(tuf.update_targets(targets).is_err());
+        assert!(tuf.update_targets(&targets).is_err());
     }
 
     #[test]
@@ -1020,7 +1019,7 @@
         let root: SignedMetadata<Json, RootMetadata> = SignedMetadata::new(&root, &KEYS[0])
             .unwrap();
 
-        let mut tuf = Tuf::from_root(root).unwrap();
+        let mut tuf = Tuf::from_root(&root).unwrap();
 
         let timestamp = TimestampMetadata::new(
             1,
@@ -1031,7 +1030,7 @@
         let timestamp: SignedMetadata<Json, TimestampMetadata> =
             SignedMetadata::new(&timestamp, &KEYS[3]).unwrap();
 
-        tuf.update_timestamp(timestamp).unwrap();
+        tuf.update_timestamp(&timestamp).unwrap();
 
         let meta_map =
             hashmap!(
@@ -1043,7 +1042,7 @@
         let snapshot: SignedMetadata<Json, SnapshotMetadata> =
             SignedMetadata::new(&snapshot, &KEYS[1]).unwrap();
 
-        tuf.update_snapshot(snapshot).unwrap();
+        tuf.update_snapshot(&snapshot).unwrap();
 
         let targets =
             TargetsMetadata::new(1, Utc.ymd(2038, 1, 1).and_hms(0, 0, 0), hashmap!(), None)
@@ -1051,6 +1050,6 @@
         let targets: SignedMetadata<Json, TargetsMetadata> =
             SignedMetadata::new(&targets, &KEYS[2]).unwrap();
 
-        assert!(tuf.update_targets(targets).is_err());
+        assert!(tuf.update_targets(&targets).is_err());
     }
 }
diff --git a/src/util.rs b/src/util.rs
index b34bdce..ea0f5b2 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -41,10 +41,10 @@
     ) -> Result<Self> {
         let hasher = match hash_data {
             Some((alg, value)) => {
-                let ctx = match alg {
-                    &HashAlgorithm::Sha256 => digest::Context::new(&SHA256),
-                    &HashAlgorithm::Sha512 => digest::Context::new(&SHA512),
-                    &HashAlgorithm::Unknown(ref s) => return Err(Error::IllegalArgument(
+                let ctx = match *alg {
+                    HashAlgorithm::Sha256 => digest::Context::new(&SHA256),
+                    HashAlgorithm::Sha512 => digest::Context::new(&SHA512),
+                    HashAlgorithm::Unknown(ref s) => return Err(Error::IllegalArgument(
                         format!("Unknown hash algorithm: {}", s)
                     )),
                 };
@@ -55,9 +55,9 @@
 
         Ok(SafeReader {
             inner: read,
-            max_size: max_size,
-            min_bytes_per_second: min_bytes_per_second,
-            hasher: hasher,
+            max_size,
+            min_bytes_per_second,
+            hasher,
             start_time: None,
             bytes_read: 0,
         })
@@ -109,9 +109,8 @@
                     }
                 }
 
-                match self.hasher {
-                    Some((ref mut context, _)) => context.update(&buf[..(read_bytes)]),
-                    None => (),
+                if let Some((ref mut context, _)) = self.hasher {
+                    context.update(&buf[..(read_bytes)]);
                 }
 
                 Ok(read_bytes)
diff --git a/tests/integration.rs b/tests/integration.rs
index 4f46a83..4a7fd3c 100644
--- a/tests/integration.rs
+++ b/tests/integration.rs
@@ -63,7 +63,7 @@
     let signed = SignedMetadata::<Json, TimestampMetadata>::new(&timestamp, &timestamp_key)
         .unwrap();
 
-    tuf.update_timestamp(signed).unwrap();
+    tuf.update_timestamp(&signed).unwrap();
 
     //// build the snapshot ////
     let meta_map =
@@ -78,11 +78,11 @@
 
     let signed = SignedMetadata::<Json, SnapshotMetadata>::new(&snapshot, &snapshot_key).unwrap();
 
-    tuf.update_snapshot(signed).unwrap();
+    tuf.update_snapshot(&signed).unwrap();
 
     //// build the targets ////
     let delegations = Delegations::new(
-        hashset![delegation_key.public().clone()],
+        &hashset![delegation_key.public().clone()],
         vec![
             Delegation::new(
                 MetadataPath::new("delegation".into()).unwrap(),
@@ -108,7 +108,7 @@
 
     let signed = SignedMetadata::<Json, TargetsMetadata>::new(&targets, &targets_key).unwrap();
 
-    tuf.update_targets(signed).unwrap();
+    tuf.update_targets(&signed).unwrap();
 
     //// build the delegation ////
     let target_file: &[u8] = b"bar";
@@ -123,7 +123,7 @@
     let signed = SignedMetadata::<Json, TargetsMetadata>::new(&delegation, &delegation_key)
         .unwrap();
 
-    tuf.update_delegation(&MetadataPath::new("delegation".into()).unwrap(), signed)
+    tuf.update_delegation(&MetadataPath::new("delegation".into()).unwrap(), &signed)
         .unwrap();
 
     assert!(
@@ -176,7 +176,7 @@
     let signed = SignedMetadata::<Json, TimestampMetadata>::new(&timestamp, &timestamp_key)
         .unwrap();
 
-    tuf.update_timestamp(signed).unwrap();
+    tuf.update_timestamp(&signed).unwrap();
 
     //// build the snapshot ////
     let meta_map =
@@ -193,11 +193,11 @@
 
     let signed = SignedMetadata::<Json, SnapshotMetadata>::new(&snapshot, &snapshot_key).unwrap();
 
-    tuf.update_snapshot(signed).unwrap();
+    tuf.update_snapshot(&signed).unwrap();
 
     //// build the targets ////
     let delegations = Delegations::new(
-        hashset![delegation_a_key.public().clone()],
+        &hashset![delegation_a_key.public().clone()],
         vec![
             Delegation::new(
                 MetadataPath::new("delegation-a".into()).unwrap(),
@@ -223,11 +223,11 @@
 
     let signed = SignedMetadata::<Json, TargetsMetadata>::new(&targets, &targets_key).unwrap();
 
-    tuf.update_targets(signed).unwrap();
+    tuf.update_targets(&signed).unwrap();
 
     //// build delegation A ////
     let delegations = Delegations::new(
-        hashset![delegation_b_key.public().clone()],
+        &hashset![delegation_b_key.public().clone()],
         vec![
             Delegation::new(
                 MetadataPath::new("delegation-b".into()).unwrap(),
@@ -254,7 +254,7 @@
     let signed = SignedMetadata::<Json, TargetsMetadata>::new(&delegation, &delegation_a_key)
         .unwrap();
 
-    tuf.update_delegation(&MetadataPath::new("delegation-a".into()).unwrap(), signed)
+    tuf.update_delegation(&MetadataPath::new("delegation-a".into()).unwrap(), &signed)
         .unwrap();
 
     //// build delegation B ////
@@ -271,7 +271,7 @@
     let signed = SignedMetadata::<Json, TargetsMetadata>::new(&delegation, &delegation_b_key)
         .unwrap();
 
-    tuf.update_delegation(&MetadataPath::new("delegation-b".into()).unwrap(), signed)
+    tuf.update_delegation(&MetadataPath::new("delegation-b".into()).unwrap(), &signed)
         .unwrap();
 
     assert!(