summaryrefslogtreecommitdiffstats
path: root/openpgp/src
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-04-06 19:58:21 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2021-04-09 13:13:58 +0200
commit9424cd350f32a97479a74d919c646f9e26c2ebce (patch)
treee7b62ae2693ccbcb73d74cacabbf6c9a31a4552e /openpgp/src
parentec5129c0863962dd3ee32b6af29be45d4d979193 (diff)
Lint: Use lazy evaluation.
- https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call
Diffstat (limited to 'openpgp/src')
-rw-r--r--openpgp/src/armor.rs2
-rw-r--r--openpgp/src/cert/amalgamation.rs2
-rw-r--r--openpgp/src/cert/builder.rs2
-rw-r--r--openpgp/src/cert/parser/mod.rs2
-rw-r--r--openpgp/src/lib.rs2
-rw-r--r--openpgp/src/policy.rs2
-rw-r--r--openpgp/src/policy/cutofflist.rs2
7 files changed, 7 insertions, 7 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index 837e3b3a..dbe007c8 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -721,7 +721,7 @@ impl<'a> Reader<'a> {
)
-> Self
{
- let mode = mode.unwrap_or(Default::default());
+ let mode = mode.unwrap_or_default();
Reader {
// The embedded generic reader's fields.
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index 3d291353..8433e43f 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -1150,7 +1150,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C>
.ok_or_else(|| {
error.map(|e| e.context(format!(
"No binding signature at time {}", crate::fmt::time(&t))))
- .unwrap_or(Error::NoBindingSignature(t).into())
+ .unwrap_or_else(|| Error::NoBindingSignature(t).into())
})
.and_then(|c| ComponentAmalgamation::new(cert, (c.0).0)
.with_policy_relaxed(policy, t, valid_cert))
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 65b9df86..84e7810e 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -260,7 +260,7 @@ impl CertBuilder<'_> {
{
CertBuilder {
creation_time: None,
- ciphersuite: ciphersuite.into().unwrap_or(Default::default()),
+ ciphersuite: ciphersuite.into().unwrap_or_default(),
primary: KeyBlueprint {
flags: KeyFlags::empty()
.set_certification(),
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs
index af5f2a38..2d62dc58 100644
--- a/openpgp/src/cert/parser/mod.rs
+++ b/openpgp/src/cert/parser/mod.rs
@@ -982,7 +982,7 @@ impl<'a> Iterator for CertParser<'a> {
_ => None,
}
.map(|s| format!(", {}", s))
- .unwrap_or("".into())
+ .unwrap_or_else(|| "".into())
);
self.source = Some(iter);
self.parse(packet)
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index da44fb4c..43b28657 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -305,7 +305,7 @@ pub enum Error {
/// determined to no longer be secure.
#[error("{0} is not considered secure{}",
.1.as_ref().map(|t| format!(" since {}", crate::fmt::time(t)))
- .unwrap_or("".into()))]
+ .unwrap_or_else(|| "".into()))]
PolicyViolation(String, Option<std::time::SystemTime>),
}
diff --git a/openpgp/src/policy.rs b/openpgp/src/policy.rs
index bb86c631..c915d06d 100644
--- a/openpgp/src/policy.rs
+++ b/openpgp/src/policy.rs
@@ -765,7 +765,7 @@ fn system_time_cutoff_to_timestamp(t: SystemTime) -> Option<Timestamp> {
// An error can only occur if the SystemTime is less than the
// reference time (SystemTime::UNIX_EPOCH). Map that to
// SystemTime::UNIX_EPOCH, as above.
- .unwrap_or(Duration::new(0, 0));
+ .unwrap_or_else(|_| Duration::new(0, 0));
let t = t.as_secs();
if t > u32::MAX as u64 {
// Map to None, as above.
diff --git a/openpgp/src/policy/cutofflist.rs b/openpgp/src/policy/cutofflist.rs
index 47d1d3e5..98d4af78 100644
--- a/openpgp/src/policy/cutofflist.rs
+++ b/openpgp/src/policy/cutofflist.rs
@@ -162,7 +162,7 @@ impl<A> CutoffList<A>
{
if let Some(cutoff) = self.cutoff(a.clone()) {
let cutoff = cutoff
- .checked_add(tolerance.unwrap_or(Duration::seconds(0)))
+ .checked_add(tolerance.unwrap_or_else(|| Duration::seconds(0)))
.unwrap_or(Timestamp::MAX);
if time >= cutoff {
Err(Error::PolicyViolation(