summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-20 19:26:48 +0300
committerLars Wirzenius <liw@liw.fi>2021-09-21 09:56:49 +0300
commit7febc9e2722f7ca97be91dc4a68c9f6a0502dc27 (patch)
tree9159e67837902e39cd251c777f66c23789920ca2 /store
parenteff8edd82629a4e6151d4bcb104a7695c6975e8d (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 'store')
-rw-r--r--store/src/backend/mod.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs
index 504a226b..2e32e825 100644
--- a/store/src/backend/mod.rs
+++ b/store/src/backend/mod.rs
@@ -1201,19 +1201,19 @@ impl fmt::Debug for node::Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "node::Error::{}",
match self {
- &node::Error::Unspecified => "Unspecified",
- &node::Error::NotFound => "NotFound",
- &node::Error::Conflict => "Conflict",
- &node::Error::SystemError => "SystemError",
- &node::Error::MalformedCert => "MalformedCert",
- &node::Error::MalformedFingerprint => "MalformedFingerprint",
- &node::Error::NetworkPolicyViolationOffline =>
+ node::Error::Unspecified => "Unspecified",
+ node::Error::NotFound => "NotFound",
+ node::Error::Conflict => "Conflict",
+ node::Error::SystemError => "SystemError",
+ node::Error::MalformedCert => "MalformedCert",
+ node::Error::MalformedFingerprint => "MalformedFingerprint",
+ node::Error::NetworkPolicyViolationOffline =>
"NetworkPolicyViolation(Offline)",
- &node::Error::NetworkPolicyViolationAnonymized =>
+ node::Error::NetworkPolicyViolationAnonymized =>
"NetworkPolicyViolation(Anonymized)",
- &node::Error::NetworkPolicyViolationEncrypted =>
+ node::Error::NetworkPolicyViolationEncrypted =>
"NetworkPolicyViolation(Encrypted)",
- &node::Error::NetworkPolicyViolationInsecure =>
+ node::Error::NetworkPolicyViolationInsecure =>
"NetworkPolicyViolation(Insecure)",
})
}
@@ -1238,7 +1238,7 @@ impl From<anyhow::Error> for node::Error {
fn from(e: anyhow::Error) -> Self {
if let Some(e) = e.downcast_ref::<openpgp::Error>() {
return match e {
- &openpgp::Error::MalformedCert(_) =>
+ openpgp::Error::MalformedCert(_) =>
node::Error::MalformedCert,
_ => node::Error::SystemError,
}
@@ -1246,15 +1246,15 @@ impl From<anyhow::Error> for node::Error {
if let Some(e) = e.downcast_ref::<super::Error>() {
return match e {
- &super::Error::NotFound => node::Error::NotFound,
- &super::Error::Conflict => node::Error::Conflict,
+ super::Error::NotFound => node::Error::NotFound,
+ super::Error::Conflict => node::Error::Conflict,
_ => unreachable!(),
}
}
if let Some(e) = e.downcast_ref::<net::Error>() {
return match e {
- &net::Error::PolicyViolation(p) =>
+ net::Error::PolicyViolation(p) =>
match p {
net::Policy::Offline =>
node::Error::NetworkPolicyViolationOffline,
@@ -1271,12 +1271,12 @@ impl From<anyhow::Error> for node::Error {
if let Some(e) = e.downcast_ref::<rusqlite::Error>() {
return match e {
- &rusqlite::Error::SqliteFailure(f, _) => match f.code {
+ rusqlite::Error::SqliteFailure(f, _) => match f.code {
rusqlite::ErrorCode::ConstraintViolation =>
node::Error::NotFound,
_ => node::Error::SystemError,
},
- &rusqlite::Error::QueryReturnedNoRows =>
+ rusqlite::Error::QueryReturnedNoRows =>
node::Error::NotFound,
_ => node::Error::SystemError,
}
@@ -1399,10 +1399,10 @@ CREATE TABLE log (
impl<'a> From<&'a net::Policy> for node::NetworkPolicy {
fn from(policy: &net::Policy) -> Self {
match policy {
- &net::Policy::Offline => node::NetworkPolicy::Offline,
- &net::Policy::Anonymized => node::NetworkPolicy::Anonymized,
- &net::Policy::Encrypted => node::NetworkPolicy::Encrypted,
- &net::Policy::Insecure => node::NetworkPolicy::Insecure,
+ net::Policy::Offline => node::NetworkPolicy::Offline,
+ net::Policy::Anonymized => node::NetworkPolicy::Anonymized,
+ net::Policy::Encrypted => node::NetworkPolicy::Encrypted,
+ net::Policy::Insecure => node::NetworkPolicy::Insecure,
}
}
}