diff options
author | Lars Wirzenius <liw@sequoia-pgp.org> | 2021-10-07 15:45:40 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2021-10-14 13:54:39 +0300 |
commit | 091f59e2cf0b51570991aefd2a728391ada1f9ce (patch) | |
tree | 54e94662c6fdcd64f8a19c650cd0c54860bc5f75 | |
parent | 54a65d0f821aa9a62bdcc04b947f6da126f36577 (diff) |
Allow clippy::unnecessary_lazy_evaluations
Replacing the closure with just the value it returns would be simpler,
but it would result in more computation happening at runtime if the
result is Ok.
See
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
This clippy warning wasn't caught by CI, because we don't yet have
clippy in CI.
-rw-r--r-- | openpgp/src/crypto/mod.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 5bcf7692..2e40451a 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -272,9 +272,10 @@ pub(crate) fn pad(value: &[u8], to: usize) -> Result<Cow<[u8]>> /// back, if necessary. If the size exceeds `to`, the value is /// returned as-is. #[allow(dead_code)] +#[allow(clippy::unnecessary_lazy_evaluations)] pub(crate) fn pad_at_least(value: &[u8], to: usize) -> Cow<[u8]> { - pad(value, to).unwrap_or_else(|_| Cow::Borrowed(value)) + pad(value, to).unwrap_or(Cow::Borrowed(value)) } /// Returns the value zero-padded or truncated to the given length. |