diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-20 19:26:48 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-09-21 09:56:49 +0300 |
commit | 7febc9e2722f7ca97be91dc4a68c9f6a0502dc27 (patch) | |
tree | 9159e67837902e39cd251c777f66c23789920ca2 /openpgp/src/types | |
parent | eff8edd82629a4e6151d4bcb104a7695c6975e8d (diff) |
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
Diffstat (limited to 'openpgp/src/types')
-rw-r--r-- | openpgp/src/types/mod.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index deec8203..cdad569f 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -426,14 +426,14 @@ impl Curve { /// ``` pub fn oid(&self) -> &[u8] { match self { - &Curve::NistP256 => NIST_P256_OID, - &Curve::NistP384 => NIST_P384_OID, - &Curve::NistP521 => NIST_P521_OID, - &Curve::BrainpoolP256 => BRAINPOOL_P256_OID, - &Curve::BrainpoolP512 => BRAINPOOL_P512_OID, - &Curve::Ed25519 => ED25519_OID, - &Curve::Cv25519 => CV25519_OID, - &Curve::Unknown(ref oid) => oid, + Curve::NistP256 => NIST_P256_OID, + Curve::NistP384 => NIST_P384_OID, + Curve::NistP521 => NIST_P521_OID, + Curve::BrainpoolP256 => BRAINPOOL_P256_OID, + Curve::BrainpoolP512 => BRAINPOOL_P512_OID, + Curve::Ed25519 => ED25519_OID, + Curve::Cv25519 => CV25519_OID, + Curve::Unknown(ref oid) => oid, } } @@ -457,14 +457,14 @@ impl Curve { /// supported. pub fn len(&self) -> Result<usize> { match self { - &Curve::NistP256 => Ok(256), - &Curve::NistP384 => Ok(384), - &Curve::NistP521 => Ok(521), - &Curve::BrainpoolP256 => Ok(256), - &Curve::BrainpoolP512 => Ok(512), - &Curve::Ed25519 => Ok(256), - &Curve::Cv25519 => Ok(256), - &Curve::Unknown(_) => + Curve::NistP256 => Ok(256), + Curve::NistP384 => Ok(384), + Curve::NistP521 => Ok(521), + Curve::BrainpoolP256 => Ok(256), + Curve::BrainpoolP512 => Ok(512), + Curve::Ed25519 => Ok(256), + Curve::Cv25519 => Ok(256), + Curve::Unknown(_) => Err(Error::UnsupportedEllipticCurve(self.clone()) .into()), } |