about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-05-05 17:52:24 +0200
committerGitHub <noreply@github.com>2021-05-05 17:52:24 +0200
commit9ffba0917bc87554087878b590b81c57600d83d0 (patch)
tree1d7c93a60d9ae1aacde2cbd4221d5cf5c94d6eb4 /library/core/src
parentdb77072a254f23b8671b263555ebe3ad88215f1e (diff)
parent2e559c8e1098545582d4a72f33e73538a5e373b5 (diff)
downloadrust-9ffba0917bc87554087878b590b81c57600d83d0.tar.gz
rust-9ffba0917bc87554087878b590b81c57600d83d0.zip
Rollup merge of #84843 - wcampbell0x2a:use-else-if-let, r=dtolnay
use else if in std library

Decreases indentation and improves readability
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/time.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/library/core/src/time.rs b/library/core/src/time.rs
index bfea39e3211..489b7224403 100644
--- a/library/core/src/time.rs
+++ b/library/core/src/time.rs
@@ -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 })