diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-21 17:07:11 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2021-09-30 08:31:04 +0300 |
commit | 581c3f0ee0d16a42ec3e74498d96da251a90672b (patch) | |
tree | e64f2cb02441bdbc2e13facde5de38948aba6276 /openpgp/src/cert/amalgamation/key | |
parent | 75b5b3fbbf8c33d10fd30e21f645b8ef1513363a (diff) |
Use the now-idiomatic option? syntax
This works in Rust now:
foo?;
as a replacement for:
if foo.is_none() {
return None;
}
It's similar to ? for error handling and can only be used in functions
that return an Option.
The instance of this in a macro caused the problem to be reported a
lot of time, once per time the macro was used, but luckily it can
could be fixed in only one place. Magic!
Found by clippy lint question_mark:
https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
Diffstat (limited to 'openpgp/src/cert/amalgamation/key')
-rw-r--r-- | openpgp/src/cert/amalgamation/key/iter.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/openpgp/src/cert/amalgamation/key/iter.rs b/openpgp/src/cert/amalgamation/key/iter.rs index f23b1a15..370a4e43 100644 --- a/openpgp/src/cert/amalgamation/key/iter.rs +++ b/openpgp/src/cert/amalgamation/key/iter.rs @@ -143,10 +143,7 @@ impl<'a, P, R> KeyAmalgamationIter<'a, P, R> tracer!(false, "KeyAmalgamationIter::next", 0); t!("KeyAmalgamationIter: {:?}", self); - if self.cert.is_none() { - return None; - } - let cert = self.cert.unwrap(); + let cert = self.cert?; loop { let ka : ErasedKeyAmalgamation<key::PublicParts> @@ -742,10 +739,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> tracer!(false, "ValidKeyAmalgamationIter::next", 0); t!("ValidKeyAmalgamationIter: {:?}", self); - if self.cert.is_none() { - return None; - } - let cert = self.cert.unwrap(); + let cert = self.cert?; if let Some(flags) = self.flags.as_ref() { if flags.is_empty() { |