summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-27 16:30:38 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:11 +0300
commit8b06d88ede1315af63250b00dbefe8ec2804eda8 (patch)
tree45a77c6ef7eae2f02cb795713fb7445e12a4c7b0 /net
parentfe78f2fc0baa68aa2b9c0125c1b89dc23121d68b (diff)
Avoid redundant closures
If a closure just passes the argument it gets to a function, the closure is usually redundant and you can just use the function instead of the closure. Thus, instead of this: iter().map(|x| foo(x)) you can write this: iter().map(foo) This is shorter and simpler. Sometimes it doesn't work and the closure is necessary. Such locations can be marked with `#[allow(clippy::redundant_closure)]`. Found by clippy lint redundant_closure: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
Diffstat (limited to 'net')
-rw-r--r--net/src/updates.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/src/updates.rs b/net/src/updates.rs
index f4ff91dc..8313cd62 100644
--- a/net/src/updates.rs
+++ b/net/src/updates.rs
@@ -79,7 +79,7 @@ impl Manifest {
/// Iterates over all epochs contained in this Update Manifest.
pub fn epochs(&self) -> impl Iterator<Item = Epoch> {
(self.start.0..self.end.0 + 1).into_iter()
- .map(|n| Epoch(n))
+ .map(Epoch)
}
/// Returns the start epoch.
@@ -218,12 +218,12 @@ impl Epoch {
/// Returns the previous Epoch, if any.
pub fn pred(&self) -> Option<Epoch> {
- self.0.checked_sub(1).map(|e| Epoch(e))
+ self.0.checked_sub(1).map(Epoch)
}
/// Returns the next Epoch, if any.
pub fn succ(&self) -> Option<Epoch> {
- self.0.checked_add(1).map(|e| Epoch(e))
+ self.0.checked_add(1).map(Epoch)
}
/// Returns an iterator over all epochs starting from this one to
@@ -231,7 +231,7 @@ impl Epoch {
pub fn since(&self, other: Epoch)
-> anyhow::Result<impl Iterator<Item = Epoch>> {
if other <= *self {
- Ok((other.0 + 1..self.0).into_iter().rev().map(|e| Epoch(e)))
+ Ok((other.0 + 1..self.0).into_iter().rev().map(Epoch))
} else {
Err(anyhow::anyhow!("other is later than self"))
}