Skip to content

Commit fb3cb14

Browse files
authored
Rollup merge of #77009 - est31:dogfood_total_cmp, r=lcnr
Dogfood total_cmp in the test crate
2 parents 48fc20c + 9172e27 commit fb3cb14

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

library/test/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![feature(staged_api)]
3030
#![feature(termination_trait_lib)]
3131
#![feature(test)]
32+
#![feature(total_cmp)]
3233

3334
// Public reexports
3435
pub use self::bench::{black_box, Bencher};

library/test/src/stats.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
#![allow(missing_docs)]
22
#![allow(deprecated)] // Float
33

4-
use std::cmp::Ordering::{self, Equal, Greater, Less};
54
use std::mem;
65

76
#[cfg(test)]
87
mod tests;
98

10-
fn local_cmp(x: f64, y: f64) -> Ordering {
11-
// arbitrarily decide that NaNs are larger than everything.
12-
if y.is_nan() {
13-
Less
14-
} else if x.is_nan() {
15-
Greater
16-
} else if x < y {
17-
Less
18-
} else if x == y {
19-
Equal
20-
} else {
21-
Greater
22-
}
23-
}
24-
259
fn local_sort(v: &mut [f64]) {
26-
v.sort_by(|x: &f64, y: &f64| local_cmp(*x, *y));
10+
v.sort_by(|x: &f64, y: &f64| x.total_cmp(y));
2711
}
2812

2913
/// Trait that provides simple descriptive statistics on a univariate set of numeric samples.

0 commit comments

Comments
 (0)