Dogfood total_cmp in the test crate
This commit is contained in:
parent
285fc7d704
commit
9172e277f8
@ -29,6 +29,7 @@
|
|||||||
#![feature(staged_api)]
|
#![feature(staged_api)]
|
||||||
#![feature(termination_trait_lib)]
|
#![feature(termination_trait_lib)]
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
#![feature(total_cmp)]
|
||||||
|
|
||||||
// Public reexports
|
// Public reexports
|
||||||
pub use self::bench::{black_box, Bencher};
|
pub use self::bench::{black_box, Bencher};
|
||||||
|
@ -1,29 +1,13 @@
|
|||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
#![allow(deprecated)] // Float
|
#![allow(deprecated)] // Float
|
||||||
|
|
||||||
use std::cmp::Ordering::{self, Equal, Greater, Less};
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
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]) {
|
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.
|
/// Trait that provides simple descriptive statistics on a univariate set of numeric samples.
|
||||||
|
Loading…
Reference in New Issue
Block a user