diff options
| author | est31 <MTest31@outlook.com> | 2020-09-21 12:13:26 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2020-09-21 12:15:30 +0200 |
| commit | 9172e277f864205daaf8fde64868d833cc6e7eb2 (patch) | |
| tree | 40e294a130c91d42b99c4b4034a9e2b529109995 | |
| parent | 285fc7d704fcdd7b2a37d475d04d5d955490e000 (diff) | |
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. |
