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/regex | |
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/regex')
-rw-r--r-- | openpgp/src/regex/mod.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/openpgp/src/regex/mod.rs b/openpgp/src/regex/mod.rs index a7e911de..0584bcbe 100644 --- a/openpgp/src/regex/mod.rs +++ b/openpgp/src/regex/mod.rs @@ -453,10 +453,8 @@ impl Regex { /// /// [`char::is_control`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_control pub fn is_match(&self, s: &str) -> bool { - if ! self.disable_sanitizations { - if s.chars().any(char::is_control) { - return false; - } + if ! self.disable_sanitizations && s.chars().any(char::is_control) { + return false; } self.is_match_clean(s) @@ -975,10 +973,8 @@ impl RegexSet { /// # Ok(()) } /// ``` pub fn is_match(&self, s: &str) -> bool { - if ! self.disable_sanitizations { - if s.chars().any(char::is_control) { - return false; - } + if ! self.disable_sanitizations && s.chars().any(char::is_control) { + return false; } match self.re_set { |