Dogfood total_cmp in the test crate

This commit is contained in:
est31 2020-09-21 12:13:26 +02:00
parent 285fc7d704
commit 9172e277f8
2 changed files with 2 additions and 17 deletions

View File

@ -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};

View File

@ -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.