diff options
author | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-03-30 22:41:53 +0200 |
---|---|---|
committer | Igor Matuszewski <xanewok@gmail.com> | 2020-03-31 11:10:44 +0000 |
commit | 4dc499e5ba33f59b1fef0a3f0efcf936b706082d (patch) | |
tree | b312cb3aced4872dd8f74f3347153e6a32ef42ff /openpgp | |
parent | 1bf00ce20f4add2e292c3f8fdeab6e370603b11a (diff) |
openpgp: Simplify hash context construction
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/crypto/hash.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/openpgp/src/crypto/hash.rs b/openpgp/src/crypto/hash.rs index a6b7df83..5c0c31e5 100644 --- a/openpgp/src/crypto/hash.rs +++ b/openpgp/src/crypto/hash.rs @@ -138,16 +138,14 @@ impl HashAlgorithm { HashAlgorithm::__Nonexhaustive => unreachable!(), }; - if let Some(prefix) = DUMP_HASHED_VALUES { - c.map(|c: Box<dyn nettle::hash::Hash>| { - Context { - algo: self, - ctx: Box::new(HashDumper::new(c, prefix)), - } - }) - } else { - c.map(|c| Context { algo: self, ctx: c }) - } + c.map(|ctx| Context { + algo: self, + ctx: if let Some(prefix) = DUMP_HASHED_VALUES { + Box::new(HashDumper::new(ctx, prefix)) + } else { + ctx + }, + }) } /// Returns the ASN.1 OID of this hash algorithm. |