#min-max #partial #partial-ord #function #nan #return

partial-min-max

min and max functions that work with PartialOrd

2 unstable releases

0.4.0 Dec 19, 2019
0.3.0 Mar 21, 2019

#13 in #partial-ord

Download history 3342/week @ 2024-01-06 2571/week @ 2024-01-13 3208/week @ 2024-01-20 4287/week @ 2024-01-27 4152/week @ 2024-02-03 4714/week @ 2024-02-10 3186/week @ 2024-02-17 4795/week @ 2024-02-24 5469/week @ 2024-03-02 5779/week @ 2024-03-09 6050/week @ 2024-03-16 7662/week @ 2024-03-23 5629/week @ 2024-03-30 6944/week @ 2024-04-06 9866/week @ 2024-04-13 7438/week @ 2024-04-20

30,788 downloads per month
Used in 26 crates (10 directly)

MIT/Apache

4KB

partial-min-max

Provides min and max functions that work with PartialOrd.

use partial_min_max::{min, max};
use std::f32::NAN;

// Does what you expect for the easy cases...
assert_eq!(min(0.0, 1.0), 0.0);
assert_eq!(max(0.0, 1.0), 1.0);

// In the case of comparisons with NaN or other partial orderings, returns the
// second value.
assert!(min(0.0, NAN).is_nan());
assert_eq!(min(NAN, 0.0), 0.0);

lib.rs:

min and max functions that work with PartialOrd.

When given NaNs and other values that don't have total orderings, the functions have well-defined (but arbitrary) behavior: return the second argument.

use partial_min_max::{min, max};
use std::f32::NAN;

// Does what you expect for the easy cases...
assert_eq!(min(0.0, 1.0), 0.0);
assert_eq!(max(0.0, 1.0), 1.0);

// In the case of comparisons with NaN or other partial orderings, returns the
// second value.
assert!(min(0.0, NAN).is_nan());
assert_eq!(min(NAN, 0.0), 0.0);

No runtime deps