From 2e559c8e1098545582d4a72f33e73538a5e373b5 Mon Sep 17 00:00:00 2001 From: wcampbell Date: Sun, 2 May 2021 20:06:17 -0400 Subject: [PATCH] use `else if` in std library Clippy: Decreases indentation and improves readability Signed-off-by: wcampbell --- library/core/src/time.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index bfea39e3211fc..489b722440362 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 })