Skip to content

Commit 7153b3d

Browse files
authored
Rollup merge of rust-lang#84843 - wcampbell0x2a:use-else-if-let, r=dtolnay
use else if in std library Decreases indentation and improves readability
2 parents df55085 + 2e559c8 commit 7153b3d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

library/core/src/time.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,11 @@ impl Duration {
518518
if let Some(mut secs) = self.secs.checked_sub(rhs.secs) {
519519
let nanos = if self.nanos >= rhs.nanos {
520520
self.nanos - rhs.nanos
521+
} else if let Some(sub_secs) = secs.checked_sub(1) {
522+
secs = sub_secs;
523+
self.nanos + NANOS_PER_SEC - rhs.nanos
521524
} else {
522-
if let Some(sub_secs) = secs.checked_sub(1) {
523-
secs = sub_secs;
524-
self.nanos + NANOS_PER_SEC - rhs.nanos
525-
} else {
526-
return None;
527-
}
525+
return None;
528526
};
529527
debug_assert!(nanos < NANOS_PER_SEC);
530528
Some(Duration { secs, nanos })

0 commit comments

Comments
 (0)