summaryrefslogtreecommitdiffstats
path: root/net
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 /net
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 'net')
-rw-r--r--net/src/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/src/lib.rs b/net/src/lib.rs
index c6eaf0a3..74f0ecfb 100644
--- a/net/src/lib.rs
+++ b/net/src/lib.rs
@@ -92,10 +92,10 @@ pub enum Policy {
impl fmt::Display for Policy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", match self {
- &Policy::Offline => "Offline",
- &Policy::Anonymized => "Anonymized",
- &Policy::Encrypted => "Encrypted",
- &Policy::Insecure => "Insecure",
+ Policy::Offline => "Offline",
+ Policy::Anonymized => "Anonymized",
+ Policy::Encrypted => "Encrypted",
+ Policy::Insecure => "Insecure",
})
}
}
@@ -115,10 +115,10 @@ impl Policy {
impl<'a> From<&'a Policy> for u8 {
fn from(policy: &Policy) -> Self {
match policy {
- &Policy::Offline => 0,
- &Policy::Anonymized => 1,
- &Policy::Encrypted => 2,
- &Policy::Insecure => 3,
+ Policy::Offline => 0,
+ Policy::Anonymized => 1,
+ Policy::Encrypted => 2,
+ Policy::Insecure => 3,
}
}
}