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 /ipc | |
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 'ipc')
-rw-r--r-- | ipc/src/core.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/ipc/src/core.rs b/ipc/src/core.rs index b4dd928a..6712921b 100644 --- a/ipc/src/core.rs +++ b/ipc/src/core.rs @@ -179,12 +179,10 @@ impl Config { let tmp = tempfile::Builder::new().prefix("sequoia").tempdir()?; c.home = tmp.into_path(); c.cleanup = true; - } else { - if home_not_set { - c.home = dirs::home_dir() - .ok_or_else(|| anyhow::anyhow!("Failed to get users home directory"))? - .join(".sequoia"); - } + } else if home_not_set { + c.home = dirs::home_dir() + .ok_or_else(|| anyhow::anyhow!("Failed to get users home directory"))? + .join(".sequoia"); } Ok(c) } |