|
| 1 | +use core::cmp::Ordering; |
1 | 2 | use core::num::FpCategory;
|
2 | 3 | use core::ops::{Add, Div, Neg};
|
3 | 4 |
|
@@ -2246,30 +2247,31 @@ pub trait TotalOrder {
|
2246 | 2247 | /// # Examples
|
2247 | 2248 | /// ```
|
2248 | 2249 | /// use num_traits::float::TotalOrder;
|
| 2250 | + /// use std::cmp::Ordering; |
2249 | 2251 | /// use std::{f32, f64};
|
2250 | 2252 | ///
|
2251 | 2253 | /// fn check_eq<T: TotalOrder>(x: T, y: T) {
|
2252 |
| - /// assert_eq!(x.total_cmp(&y), std::cmp::Ordering::Equal); |
| 2254 | + /// assert_eq!(x.total_cmp(&y), Ordering::Equal); |
2253 | 2255 | /// }
|
2254 | 2256 | ///
|
2255 | 2257 | /// check_eq(f64::NAN, f64::NAN);
|
2256 | 2258 | /// check_eq(f32::NAN, f32::NAN);
|
2257 | 2259 | ///
|
2258 | 2260 | /// fn check_lt<T: TotalOrder>(x: T, y: T) {
|
2259 |
| - /// assert_eq!(x.total_cmp(&y), std::cmp::Ordering::Less); |
| 2261 | + /// assert_eq!(x.total_cmp(&y), Ordering::Less); |
2260 | 2262 | /// }
|
2261 | 2263 | ///
|
2262 | 2264 | /// check_lt(-f64::NAN, f64::NAN);
|
2263 | 2265 | /// check_lt(f64::INFINITY, f64::NAN);
|
2264 | 2266 | /// check_lt(-0.0_f64, 0.0_f64);
|
2265 | 2267 | /// ```
|
2266 |
| - fn total_cmp(&self, other: &Self) -> std::cmp::Ordering; |
| 2268 | + fn total_cmp(&self, other: &Self) -> Ordering; |
2267 | 2269 | }
|
2268 | 2270 | macro_rules! totalorder_impl {
|
2269 | 2271 | ($T:ident) => {
|
2270 | 2272 | impl TotalOrder for $T {
|
2271 | 2273 | #[inline]
|
2272 |
| - fn total_cmp(&self, other: &Self) -> std::cmp::Ordering { |
| 2274 | + fn total_cmp(&self, other: &Self) -> Ordering { |
2273 | 2275 | Self::total_cmp(&self, other)
|
2274 | 2276 | }
|
2275 | 2277 | }
|
@@ -2413,14 +2415,17 @@ mod tests {
|
2413 | 2415 | #[test]
|
2414 | 2416 | fn total_cmp() {
|
2415 | 2417 | use crate::float::{Float, TotalOrder};
|
| 2418 | + use core::cmp::Ordering; |
| 2419 | + use core::{f32, f64}; |
| 2420 | + |
2416 | 2421 | fn check_eq<T: Float + TotalOrder>(x: T, y: T) {
|
2417 |
| - assert_eq!(x.total_cmp(&y), std::cmp::Ordering::Equal); |
| 2422 | + assert_eq!(x.total_cmp(&y), Ordering::Equal); |
2418 | 2423 | }
|
2419 | 2424 | fn check_lt<T: Float + TotalOrder>(x: T, y: T) {
|
2420 |
| - assert_eq!(x.total_cmp(&y), std::cmp::Ordering::Less); |
| 2425 | + assert_eq!(x.total_cmp(&y), Ordering::Less); |
2421 | 2426 | }
|
2422 | 2427 | fn check_gt<T: Float + TotalOrder>(x: T, y: T) {
|
2423 |
| - assert_eq!(x.total_cmp(&y), std::cmp::Ordering::Greater); |
| 2428 | + assert_eq!(x.total_cmp(&y), Ordering::Greater); |
2424 | 2429 | }
|
2425 | 2430 |
|
2426 | 2431 | check_eq(f64::NAN, f64::NAN);
|
|
0 commit comments