diff options
| author | Ralf Jung <post@ralfj.de> | 2020-09-21 15:30:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-21 15:30:49 +0200 |
| commit | fb3cb14af680b2940955c491f79f3293bd9a060b (patch) | |
| tree | d90ccb4af9a09638f7ac21ff716dac62610d70d4 | |
| parent | 48fc20cc471c6c0f16c291fc5801ede05126103a (diff) | |
| parent | 9172e277f864205daaf8fde64868d833cc6e7eb2 (diff) | |
| download | rust-fb3cb14af680b2940955c491f79f3293bd9a060b.tar.gz rust-fb3cb14af680b2940955c491f79f3293bd9a060b.zip | |
Rollup merge of #77009 - est31:dogfood_total_cmp, r=lcnr
Dogfood total_cmp in the test crate
| -rw-r--r-- | library/test/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/test/src/stats.rs | 18 |
2 files changed, 2 insertions, 17 deletions
diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 6bd708ef487..caea4b1e309 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -29,6 +29,7 @@ #![feature(staged_api)] #![feature(termination_trait_lib)] #![feature(test)] +#![feature(total_cmp)] // Public reexports pub use self::bench::{black_box, Bencher}; diff --git a/library/test/src/stats.rs b/library/test/src/stats.rs index c02f93bf9d4..1a2cb893a8a 100644 --- a/library/test/src/stats.rs +++ b/library/test/src/stats.rs @@ -1,29 +1,13 @@ #![allow(missing_docs)] #![allow(deprecated)] // Float -use std::cmp::Ordering::{self, Equal, Greater, Less}; use std::mem; #[cfg(test)] mod tests; -fn local_cmp(x: f64, y: f64) -> Ordering { - // arbitrarily decide that NaNs are larger than everything. - if y.is_nan() { - Less - } else if x.is_nan() { - Greater - } else if x < y { - Less - } else if x == y { - Equal - } else { - Greater - } -} - fn local_sort(v: &mut [f64]) { - v.sort_by(|x: &f64, y: &f64| local_cmp(*x, *y)); + v.sort_by(|x: &f64, y: &f64| x.total_cmp(y)); } /// Trait that provides simple descriptive statistics on a univariate set of numeric samples. |
