From 8b06d88ede1315af63250b00dbefe8ec2804eda8 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 27 Sep 2021 16:30:38 +0300 Subject: 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 --- ipc/src/keybox.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ipc') diff --git a/ipc/src/keybox.rs b/ipc/src/keybox.rs index 7ed481b7..c098631d 100644 --- a/ipc/src/keybox.rs +++ b/ipc/src/keybox.rs @@ -162,13 +162,13 @@ impl KeyboxRecord { let record = KeyboxRecord::Unknown(bytes.clone()); match record.typ() { KeyboxRecordType::Header => { - HeaderRecord::new(bytes).map(|r| KeyboxRecord::Header(r)) + HeaderRecord::new(bytes).map(KeyboxRecord::Header) } KeyboxRecordType::OpenPGP => { - OpenPGPRecordV1::new(&record).map(|r| KeyboxRecord::OpenPGP(r)) + OpenPGPRecordV1::new(&record).map(KeyboxRecord::OpenPGP) } KeyboxRecordType::X509 => { - X509Record::new(bytes).map(|r| KeyboxRecord::X509(r)) + X509Record::new(bytes).map(KeyboxRecord::X509) } KeyboxRecordType::Unknown(_) => Ok(record), } -- cgit v1.2.3