diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-27 18:49:32 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2021-09-30 08:31:12 +0300 |
commit | d7cb7da07661ce42c36ba2dd4bc0edcad11a7e81 (patch) | |
tree | 830a8bcde3f3b6537af99976d5e8385bf4a42e83 /openpgp/src/cert/amalgamation/key | |
parent | 28f1cef827fc738f48b723974f4fe4229ad6dc67 (diff) |
Join nested if statements with logical and into one statement
Instead of this:
if foo {
if bar {
...
}
}
do this:
if foo && bar {
...
}
Nesting statements implies a more complicated code structure than it
really is. Thus it's arguably simpler to write a combined condition by
joining the two conditions with a logical and operation.
Found by clippy lint collapsible_if:
https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
Diffstat (limited to 'openpgp/src/cert/amalgamation/key')
-rw-r--r-- | openpgp/src/cert/amalgamation/key/iter.rs | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/openpgp/src/cert/amalgamation/key/iter.rs b/openpgp/src/cert/amalgamation/key/iter.rs index 370a4e43..d2ec0fe6 100644 --- a/openpgp/src/cert/amalgamation/key/iter.rs +++ b/openpgp/src/cert/amalgamation/key/iter.rs @@ -175,11 +175,9 @@ impl<'a, P, R> KeyAmalgamationIter<'a, P, R> t!("PK algo is supported... skipping."); continue; } - } else { - if want_supported { - t!("PK algo is not supported... skipping."); - continue; - } + } else if want_supported { + t!("PK algo is not supported... skipping."); + continue; } } @@ -190,11 +188,9 @@ impl<'a, P, R> KeyAmalgamationIter<'a, P, R> t!("Have a secret... skipping."); continue; } - } else { - if want_secret { - t!("No secret... skipping."); - continue; - } + } else if want_secret { + t!("No secret... skipping."); + continue; } } @@ -205,11 +201,9 @@ impl<'a, P, R> KeyAmalgamationIter<'a, P, R> t!("Unencrypted secret... skipping."); continue; } - } else { - if want_unencrypted_secret { - t!("Encrypted secret... skipping."); - continue; - } + } else if want_unencrypted_secret { + t!("Encrypted secret... skipping."); + continue; } } else { // No secret. @@ -797,11 +791,9 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> t!("PK algo is supported... skipping."); continue; } - } else { - if want_supported { - t!("PK algo is not supported... skipping."); - continue; - } + } else if want_supported { + t!("PK algo is not supported... skipping."); + continue; } } @@ -843,11 +835,9 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> t!("Have a secret... skipping."); continue; } - } else { - if want_secret { - t!("No secret... skipping."); - continue; - } + } else if want_secret { + t!("No secret... skipping."); + continue; } } @@ -858,11 +848,9 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> t!("Unencrypted secret... skipping."); continue; } - } else { - if want_unencrypted_secret { - t!("Encrypted secret... skipping."); - continue; - } + } else if want_unencrypted_secret { + t!("Encrypted secret... skipping."); + continue; } } else { // No secret. |