#partial-ord #nan

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 8115/week @ 2024-07-19 6146/week @ 2024-07-26 7398/week @ 2024-08-02 8999/week @ 2024-08-09 10710/week @ 2024-08-16 6102/week @ 2024-08-23 7121/week @ 2024-08-30 9096/week @ 2024-09-06 7880/week @ 2024-09-13 6291/week @ 2024-09-20 8789/week @ 2024-09-27 5577/week @ 2024-10-04 8326/week @ 2024-10-11 7172/week @ 2024-10-18 6101/week @ 2024-10-25 8114/week @ 2024-11-01

30,587 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