From 9172e277f864205daaf8fde64868d833cc6e7eb2 Mon Sep 17 00:00:00 2001 From: est31 Date: Mon, 21 Sep 2020 12:13:26 +0200 Subject: [PATCH] Dogfood total_cmp in the test crate --- library/test/src/lib.rs | 1 + 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. -- 2.44.0