Skip to content

Commit

Permalink
Dogfood total_cmp in the test crate
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Sep 21, 2020
1 parent 285fc7d commit 9172e27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
1 change: 1 addition & 0 deletions library/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
18 changes: 1 addition & 17 deletions library/test/src/stats.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 9172e27

Please sign in to comment.