diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-07 16:12:06 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-09 13:13:58 +0200 |
commit | a23a14d0471512d360364b69df51161e84c9e0d0 (patch) | |
tree | 96f9c3d1ba810656bc72788bb354d727772b4fb9 | |
parent | 0c538f122d7a498a58f9b380b6be03a40f827c3e (diff) |
Lint: Remove redundant closures.
- https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
-rw-r--r-- | ffi/src/core.rs | 4 | ||||
-rw-r--r-- | ffi/src/net.rs | 2 | ||||
-rw-r--r-- | openpgp-ffi/src/armor.rs | 10 | ||||
-rw-r--r-- | openpgp-ffi/src/io.rs | 4 | ||||
-rw-r--r-- | openpgp-ffi/src/parse/stream.rs | 2 | ||||
-rw-r--r-- | openpgp-ffi/src/serialize.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/parse.rs | 2 | ||||
-rw-r--r-- | openpgp/src/parse/hashed_reader.rs | 4 | ||||
-rw-r--r-- | openpgp/src/regex/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/serialize/stream/dash_escape.rs | 2 | ||||
-rw-r--r-- | openpgp/src/serialize/stream/trim_whitespace.rs | 2 | ||||
-rw-r--r-- | openpgp/src/types/timestamp.rs | 4 | ||||
-rw-r--r-- | sq/src/commands/keyring.rs | 2 | ||||
-rw-r--r-- | sqv/src/sqv.rs | 2 |
15 files changed, 24 insertions, 24 deletions
diff --git a/ffi/src/core.rs b/ffi/src/core.rs index 59f465b7..2879006b 100644 --- a/ffi/src/core.rs +++ b/ffi/src/core.rs @@ -88,7 +88,7 @@ fn sq_context_last_error(ctx: *mut Context) -> *mut crate::error::Error { fn sq_context_new(errp: Option<&mut *mut crate::error::Error>) -> *mut Context { ffi_make_fry_from_errp!(errp); - ffi_try_box!(core::Context::new().map(|ctx| Context::new(ctx))) + ffi_try_box!(core::Context::new().map(Context::new)) } /// Frees a context. @@ -148,7 +148,7 @@ fn sq_config_build(cfg: *mut Config, errp: Option<&mut *mut crate::error::Error> ffi_make_fry_from_errp!(errp); let cfg = ffi_param_move!(cfg); - ffi_try_box!(cfg.build().map(|ctx| Context::new(ctx))) + ffi_try_box!(cfg.build().map(Context::new)) } /// Sets the directory containing shared state. diff --git a/ffi/src/net.rs b/ffi/src/net.rs index 906f1999..ce1888b8 100644 --- a/ffi/src/net.rs +++ b/ffi/src/net.rs @@ -89,7 +89,7 @@ fn sq_keyserver_with_cert(ctx: *mut Context, policy: u8, }; let cert = ffi_try!(Certificate::from_der(cert) - .map_err(|e| ::anyhow::Error::from(e))); + .map_err(::anyhow::Error::from)); ffi_try_box!(KeyServer::with_cert(policy, &uri, cert)) } diff --git a/openpgp-ffi/src/armor.rs b/openpgp-ffi/src/armor.rs index 71ee8539..85916e29 100644 --- a/openpgp-ffi/src/armor.rs +++ b/openpgp-ffi/src/armor.rs @@ -142,8 +142,8 @@ pub extern "C" fn pgp_armor_reader_from_file(errp: Option<&mut *mut crate::error let mode = int_to_reader_mode(mode); armor::Reader::from_file(&filename, mode) - .map(|r| ReaderKind::Armored(r)) - .map_err(|e| ::anyhow::Error::from(e)) + .map(ReaderKind::Armored) + .map_err(::anyhow::Error::from) .move_into_raw(errp) } @@ -270,7 +270,7 @@ pub extern "C" fn pgp_armor_reader_headers(errp: Option<&mut *mut crate::error:: expected armor reader"); }; - match reader.headers().map_err(|e| ::anyhow::Error::from(e)) { + match reader.headers().map_err(::anyhow::Error::from) { Ok(headers) => { // Allocate space for the result. let buf = unsafe { @@ -390,8 +390,8 @@ pub extern "C" fn pgp_armor_writer_new header_.iter().map(|h| (h.0.as_ref(), h.1.as_ref())).collect(); armor::Writer::with_headers(inner, kind, header) - .map(|w| WriterKind::Armored(w)) - .map_err(|e| ::anyhow::Error::from(e)) + .map(WriterKind::Armored) + .map_err(::anyhow::Error::from) .move_into_raw(errp) } diff --git a/openpgp-ffi/src/io.rs b/openpgp-ffi/src/io.rs index 3c5668d6..b61e2638 100644 --- a/openpgp-ffi/src/io.rs +++ b/openpgp-ffi/src/io.rs @@ -48,7 +48,7 @@ pub extern "C" fn pgp_reader_from_file(errp: Option<&mut *mut crate::error::Erro let filename = ffi_param_cstr!(filename).to_string_lossy().into_owned(); File::open(Path::new(&filename)) .map(|r| ReaderKind::Generic(Box::new(r))) - .map_err(|e| ::anyhow::Error::from(e)) + .map_err(::anyhow::Error::from) .move_into_raw(errp) } @@ -229,7 +229,7 @@ fn pgp_writer_from_file(errp: Option<&mut *mut crate::error::Error>, let filename = ffi_param_cstr!(filename).to_string_lossy().into_owned(); File::create(Path::new(&filename)) .map(|w| WriterKind::Generic(Box::new(w))) - .map_err(|e| ::anyhow::Error::from(e)) + .map_err(::anyhow::Error::from) .move_into_raw(errp) } diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs index f5f6a206..8f889b14 100644 --- a/openpgp-ffi/src/parse/stream.rs +++ b/openpgp-ffi/src/parse/stream.rs @@ -895,7 +895,7 @@ impl DecryptionHelper for DHelper { let result = (self.decrypt_cb)( closure.cookie, pkesks.as_ptr(), pkesks.len(), skesks.as_ptr(), skesks.len(), - sym_algo.map(|s| u8::from(s)).unwrap_or(0), + sym_algo.map(u8::from).unwrap_or(0), trampoline::<D>, &mut decrypt as *mut _ as *mut c_void, &mut identity); diff --git a/openpgp-ffi/src/serialize.rs b/openpgp-ffi/src/serialize.rs index 053fedbb..0d654457 100644 --- a/openpgp-ffi/src/serialize.rs +++ b/openpgp-ffi/src/serialize.rs @@ -64,7 +64,7 @@ pub extern "C" fn pgp_writer_stack_write let buf = unsafe { slice::from_raw_parts(buf, len as usize) }; - ffi_try_or!(writer.write(buf).map_err(|e| ::anyhow::Error::from(e)), -1) as ssize_t + ffi_try_or!(writer.write(buf).map_err(::anyhow::Error::from), -1) as ssize_t } /// Writes up to `len` bytes of `buf` into `writer`. @@ -85,7 +85,7 @@ pub extern "C" fn pgp_writer_stack_write_all let buf = unsafe { slice::from_raw_parts(buf, len as usize) }; - ffi_try_status!(writer.write_all(buf).map_err(|e| ::anyhow::Error::from(e))) + ffi_try_status!(writer.write_all(buf).map_err(::anyhow::Error::from)) } /// Finalizes this writer, returning the underlying writer. diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index ae92462a..52a58f56 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -646,7 +646,7 @@ impl<'a> Iterator for Iter<'a> { // Get the next child and the iterator for its children. self.child = self.children.next(); if let Some(child) = self.child { - self.grandchildren = child.descendants().map(|d| Box::new(d)); + self.grandchildren = child.descendants().map(Box::new); } // First return the child itself. Subsequent calls will diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index 30593e82..f27a2bef 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -2637,7 +2637,7 @@ impl SKESK { // parameters if the S2K method is not supported, and // we don't know the size of the ESK. let mut esk = php_try!(php.reader.steal_eof() - .map_err(|e| anyhow::Error::from(e))); + .map_err(anyhow::Error::from)); let aead_iv = if s2k_supported && esk.len() >= iv_size { // We know the S2K method, so the parameters have // been parsed into the S2K object. So, `esk` diff --git a/openpgp/src/parse/hashed_reader.rs b/openpgp/src/parse/hashed_reader.rs index 4db0a0ee..2d301b1e 100644 --- a/openpgp/src/parse/hashed_reader.rs +++ b/openpgp/src/parse/hashed_reader.rs @@ -422,7 +422,7 @@ mod test { let mut reader = HashedReader::new(reader, HashesFor::MDC, test.expected.keys().cloned() - .map(|algo| HashingMode::Binary(algo)) + .map(HashingMode::Binary) .collect()); assert_eq!(reader.steal_eof().unwrap(), test.data); @@ -485,7 +485,7 @@ mod test { hash_buffered_reader( reader, &expected.keys().cloned() - .map(|algo| HashingMode::Binary(algo)). + .map(HashingMode::Binary). collect::<Vec<_>>()) .unwrap(); diff --git a/openpgp/src/regex/mod.rs b/openpgp/src/regex/mod.rs index c45e0eb0..31e3c7e3 100644 --- a/openpgp/src/regex/mod.rs +++ b/openpgp/src/regex/mod.rs @@ -308,7 +308,7 @@ fn generate_class(caret: bool, chars: impl Iterator<Item=char>) -> Hir // Pad it out so what we can use windows to get three // characters at a time, and be sure to process all // characters. - .map(|c| Some(c)) + .map(Some) .chain(std::iter::once(None)) .chain(std::iter::once(None)) .collect(); diff --git a/openpgp/src/serialize/stream/dash_escape.rs b/openpgp/src/serialize/stream/dash_escape.rs index 52440b17..c84f3f0c 100644 --- a/openpgp/src/serialize/stream/dash_escape.rs +++ b/openpgp/src/serialize/stream/dash_escape.rs @@ -81,7 +81,7 @@ impl<'a, C: 'a> DashEscapeFilter<'a, C> { } let new_buffer = last_line.map(|l| l.to_vec()) - .unwrap_or_else(|| Vec::new()); + .unwrap_or_else(Vec::new); crate::vec_truncate(&mut self.buffer, 0); self.buffer = new_buffer; diff --git a/openpgp/src/serialize/stream/trim_whitespace.rs b/openpgp/src/serialize/stream/trim_whitespace.rs index 79cf70b8..1236b6f6 100644 --- a/openpgp/src/serialize/stream/trim_whitespace.rs +++ b/openpgp/src/serialize/stream/trim_whitespace.rs @@ -90,7 +90,7 @@ impl<'a, C: 'a> TrailingWSFilter<'a, C> { } let new_buffer = last_line.map(|l| l.to_vec()) - .unwrap_or_else(|| Vec::new()); + .unwrap_or_else(Vec::new); crate::vec_truncate(&mut self.buffer, 0); self.buffer = new_buffer; diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs index 78c5180f..fb18f082 100644 --- a/openpgp/src/types/timestamp.rs +++ b/openpgp/src/types/timestamp.rs @@ -133,7 +133,7 @@ impl Timestamp { /// Returns `None` if the resulting timestamp is not /// representable. pub fn checked_add(&self, d: Duration) -> Option<Timestamp> { - self.0.checked_add(d.0).map(|v| Self(v)) + self.0.checked_add(d.0).map(Self) } /// Subtracts a duration from this timestamp. @@ -141,7 +141,7 @@ impl Timestamp { /// Returns `None` if the resulting timestamp is not /// representable. pub fn checked_sub(&self, d: Duration) -> Option<Timestamp> { - self.0.checked_sub(d.0).map(|v| Self(v)) + self.0.checked_sub(d.0).map(Self) } /// Rounds down to the given level of precision. diff --git a/sq/src/commands/keyring.rs b/sq/src/commands/keyring.rs index a7083c1d..a0fc92d2 100644 --- a/sq/src/commands/keyring.rs +++ b/sq/src/commands/keyring.rs @@ -143,7 +143,7 @@ pub fn dispatch(config: Config, m: &clap::ArgMatches) -> Result<()> { config.create_or_stdout_pgp(m.value_of("output"), m.is_present("binary"), armor::Kind::PublicKey)?; - filter(m.values_of("input"), &mut output, |c| Some(c), false)?; + filter(m.values_of("input"), &mut output, Some, false)?; output.finalize() }, ("merge", Some(m)) => { diff --git a/sqv/src/sqv.rs b/sqv/src/sqv.rs index f84cef9e..2ba9765a 100644 --- a/sqv/src/sqv.rs +++ b/sqv/src/sqv.rs @@ -274,7 +274,7 @@ fn main() -> Result<()> { .into()) } else { None - }.unwrap_or_else(|| std::time::SystemTime::now()); + }.unwrap_or_else(std::time::SystemTime::now); let keyrings = matches.values_of_os("keyring") .expect("No keyring specified."); |