]> git.lizzy.rs Git - rust.git/commitdiff
Refactor collapsible_if
authorwcampbell <wcampbell1995@gmail.com>
Tue, 13 Oct 2020 21:50:10 +0000 (17:50 -0400)
committerwcampbell <wcampbell1995@gmail.com>
Tue, 13 Oct 2020 21:50:10 +0000 (17:50 -0400)
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
library/std/src/f64.rs

index bd094bdb55dc343da3c1eb033cd52aed2ff30f7c..2ecb0f44d001b6491c7e0e77705b3ebac5876882 100644 (file)
@@ -920,22 +920,20 @@ pub fn clamp(self, min: f64, max: f64) -> f64 {
     fn log_wrapper<F: Fn(f64) -> f64>(self, log_fn: F) -> f64 {
         if !cfg!(any(target_os = "solaris", target_os = "illumos")) {
             log_fn(self)
-        } else {
-            if self.is_finite() {
-                if self > 0.0 {
-                    log_fn(self)
-                } else if self == 0.0 {
-                    Self::NEG_INFINITY // log(0) = -Inf
-                } else {
-                    Self::NAN // log(-n) = NaN
-                }
-            } else if self.is_nan() {
-                self // log(NaN) = NaN
-            } else if self > 0.0 {
-                self // log(Inf) = Inf
+        } else if self.is_finite() {
+            if self > 0.0 {
+                log_fn(self)
+            } else if self == 0.0 {
+                Self::NEG_INFINITY // log(0) = -Inf
             } else {
-                Self::NAN // log(-Inf) = NaN
+                Self::NAN // log(-n) = NaN
             }
+        } else if self.is_nan() {
+            self // log(NaN) = NaN
+        } else if self > 0.0 {
+            self // log(Inf) = Inf
+        } else {
+            Self::NAN // log(-Inf) = NaN
         }
     }
 }