From 7febc9e2722f7ca97be91dc4a68c9f6a0502dc27 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 20 Sep 2021 19:26:48 +0300 Subject: Avoid matching on &Foo, when a plain Foo pattern works The extra & in a pattern (match arm or if let) is unnecessary and only makes the code harder to read. In most places it's enough to just remove the & from the pattern, but in a few places a dereference (*) needs to be added where the value captured in the pattern is used, as removing the & changes the type of the captured value to be a reference. Overall, the changes are almost mechanical. Although the diff is huge, it should be easy to read. The clippy lint match_ref_pats warns about this. See: https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats --- openpgp/src/keyid.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'openpgp/src/keyid.rs') diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs index 632b9439..6186d208 100644 --- a/openpgp/src/keyid.rs +++ b/openpgp/src/keyid.rs @@ -240,8 +240,8 @@ impl KeyID { /// ``` pub fn as_bytes(&self) -> &[u8] { match self { - &KeyID::V4(ref id) => id, - &KeyID::Invalid(ref id) => id, + KeyID::V4(ref id) => id, + KeyID::Invalid(ref id) => id, } } @@ -353,8 +353,8 @@ impl KeyID { /// Common code for the above functions. fn convert_to_string(&self, pretty: bool) -> String { let raw = match self { - &KeyID::V4(ref fp) => &fp[..], - &KeyID::Invalid(ref fp) => &fp[..], + KeyID::V4(ref fp) => &fp[..], + KeyID::Invalid(ref fp) => &fp[..], }; // We currently only handle V4 Key IDs, which look like: -- cgit v1.2.3