Skip to content

Commit

Permalink
Rollup merge of rust-lang#84843 - wcampbell0x2a:use-else-if-let, r=dt…
Browse files Browse the repository at this point in the history
…olnay

use else if in std library

Decreases indentation and improves readability
  • Loading branch information
Dylan-DPC authored May 4, 2021
2 parents df55085 + 2e559c8 commit 7153b3d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 7153b3d

Please sign in to comment.