diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-11-22 16:12:08 +0100 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-11-29 11:53:55 +0100 |
commit | 0b7bff7337dd94422faf0a3172180ec8c28b1545 (patch) | |
tree | 7f4bccb4b9f6d3f251b38e6007e15b47f13baa31 /openpgp | |
parent | 566177a617c55b7c15dc27ed682b4a2324951cdb (diff) |
openpgp: Apply clippy::manual_map.
- Improve clarity by replacing
match Some(0) {
Some(x) => Some(x + 1),
None => None,
};
with Some(0).map(|x| x + 1);
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/packet/literal.rs | 9 | ||||
-rw-r--r-- | openpgp/src/packet/signature.rs | 13 | ||||
-rw-r--r-- | openpgp/src/parse/partial_body.rs | 6 |
3 files changed, 12 insertions, 16 deletions
diff --git a/openpgp/src/packet/literal.rs b/openpgp/src/packet/literal.rs index 14b98b38..f534f51c 100644 --- a/openpgp/src/packet/literal.rs +++ b/openpgp/src/packet/literal.rs @@ -51,11 +51,10 @@ assert_send_and_sync!(Literal); impl fmt::Debug for Literal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let filename = if let Some(ref filename) = self.filename { - Some(String::from_utf8_lossy(filename)) - } else { - None - }; + let filename = self + .filename + .as_ref() + .map(|filename| String::from_utf8_lossy(filename)); let threshold = 36; let body = self.body(); diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs index 464e30cd..bc48b733 100644 --- a/openpgp/src/packet/signature.rs +++ b/openpgp/src/packet/signature.rs @@ -1750,12 +1750,13 @@ impl fmt::Debug for Signature4 { .field("additional_issuers", &self.additional_issuers) .field("digest_prefix", &crate::fmt::to_hex(&self.digest_prefix, false)) - .field("computed_digest", - &if let Some(ref hash) = self.computed_digest { - Some(crate::fmt::to_hex(&hash[..], false)) - } else { - None - }) + .field( + "computed_digest", + &self + .computed_digest + .as_ref() + .map(|hash| crate::fmt::to_hex(&hash[..], false)), + ) .field("level", &self.level) .field("mpis", &self.mpis) .finish() diff --git a/openpgp/src/parse/partial_body.rs b/openpgp/src/parse/partial_body.rs index e0904869..0ae9bad4 100644 --- a/openpgp/src/parse/partial_body.rs +++ b/openpgp/src/parse/partial_body.rs @@ -59,11 +59,7 @@ impl<T: BufferedReader<Cookie>> std::fmt::Debug .field("last", &self.last) .field("hash headers", &self.hash_headers) .field("buffer (bytes left)", - &if let Some(ref buffer) = self.buffer { - Some(buffer.len()) - } else { - None - }) + &self.buffer.as_ref().map(|buffer| buffer.len())) .field("reader", &self.reader) .finish() } |