diff options
| author | wcampbell <wcampbell1995@gmail.com> | 2020-10-13 17:50:10 -0400 |
|---|---|---|
| committer | wcampbell <wcampbell1995@gmail.com> | 2020-10-13 17:50:10 -0400 |
| commit | 096722ff7647c42fe221c0d99892a72e596b6a56 (patch) | |
| tree | 0c2dfc170dd4500f2bef092e61437658c0082187 | |
| parent | abbdec3be6cfce1175d0dc6737a2999cf43b530d (diff) | |
| download | rust-096722ff7647c42fe221c0d99892a72e596b6a56.tar.gz rust-096722ff7647c42fe221c0d99892a72e596b6a56.zip | |
Refactor collapsible_if
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
| -rw-r--r-- | library/std/src/f64.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index bd094bdb55d..2ecb0f44d00 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -920,22 +920,20 @@ impl 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 } } } |
