#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

#12 in #partial-ord

Download history 6740/week @ 2024-03-13 6461/week @ 2024-03-20 6680/week @ 2024-03-27 5566/week @ 2024-04-03 8643/week @ 2024-04-10 9623/week @ 2024-04-17 5269/week @ 2024-04-24 6121/week @ 2024-05-01 4107/week @ 2024-05-08 4905/week @ 2024-05-15 8742/week @ 2024-05-22 8207/week @ 2024-05-29 7299/week @ 2024-06-05 8119/week @ 2024-06-12 8144/week @ 2024-06-19 7642/week @ 2024-06-26

32,466 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