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/parse.rs | |
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/parse.rs')
-rw-r--r-- | openpgp/src/parse.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index 8a323b89..5cf7c5f5 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -2229,12 +2229,10 @@ impl Key4<key::UnspecifiedParts, key::UnspecifiedRole> format!("Unexpected secret key found in {:?} packet", tag) ).into()); } - } else { - if tag == Tag::SecretKey || tag == Tag::SecretSubkey { - return php.error(Error::MalformedPacket( - format!("Expected secret key in {:?} packet", tag) - ).into()); - } + } else if tag == Tag::SecretKey || tag == Tag::SecretSubkey { + return php.error(Error::MalformedPacket( + format!("Expected secret key in {:?} packet", tag) + ).into()); } fn k<R>(creation_time: u32, |