#min-max #partial-ord #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 8585/week @ 2025-10-01 9808/week @ 2025-10-08 8159/week @ 2025-10-15 9187/week @ 2025-10-22 7082/week @ 2025-10-29 8135/week @ 2025-11-05 6415/week @ 2025-11-12 7358/week @ 2025-11-19 5121/week @ 2025-11-26 9192/week @ 2025-12-03 7175/week @ 2025-12-10 7383/week @ 2025-12-17 6520/week @ 2025-12-24 7358/week @ 2025-12-31 7608/week @ 2026-01-07 7786/week @ 2026-01-14

30,444 downloads per month
Used in 27 crates (10 directly)

MIT/Apache

4KB

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);

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);

No runtime deps