diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-10-30 18:00:49 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-30 18:00:49 +0900 |
| commit | 02a4b58a3fe3d245417b47b8a9ebb146fbe5b413 (patch) | |
| tree | dca271e5954f91fb92195946bd1d406f4e5d65cd | |
| parent | 439ea4b62193eeb784a9511b2257921109bb19c0 (diff) | |
| parent | 096722ff7647c42fe221c0d99892a72e596b6a56 (diff) | |
| download | rust-02a4b58a3fe3d245417b47b8a9ebb146fbe5b413.tar.gz rust-02a4b58a3fe3d245417b47b8a9ebb146fbe5b413.zip | |
Rollup merge of #77921 - wcampbell0x2a:f64-collapsible-if, r=jyn514
f64: Refactor collapsible_if
| -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 } } } |
