Rollup merge of #84843 - wcampbell0x2a:use-else-if-let, r=dtolnay

use else if in std library

Decreases indentation and improves readability
This commit is contained in:
Ralf Jung 2021-05-05 17:52:24 +02:00 committed by GitHub
commit 9ffba0917b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -518,13 +518,11 @@ impl Duration {
if let Some(mut secs) = self.secs.checked_sub(rhs.secs) {
let nanos = if self.nanos >= rhs.nanos {
self.nanos - rhs.nanos
} else if let Some(sub_secs) = secs.checked_sub(1) {
secs = sub_secs;
self.nanos + NANOS_PER_SEC - rhs.nanos
} else {
if let Some(sub_secs) = secs.checked_sub(1) {
secs = sub_secs;
self.nanos + NANOS_PER_SEC - rhs.nanos
} else {
return None;
}
return None;
};
debug_assert!(nanos < NANOS_PER_SEC);
Some(Duration { secs, nanos })