#min-max #partial #partial-ord #work #nan #functions #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

#14 in #min-max

Download history 4981/week @ 2023-11-20 6732/week @ 2023-11-27 6442/week @ 2023-12-04 5205/week @ 2023-12-11 4446/week @ 2023-12-18 2942/week @ 2023-12-25 3259/week @ 2024-01-01 3261/week @ 2024-01-08 2653/week @ 2024-01-15 3073/week @ 2024-01-22 4396/week @ 2024-01-29 4311/week @ 2024-02-05 4605/week @ 2024-02-12 3415/week @ 2024-02-19 4747/week @ 2024-02-26 5639/week @ 2024-03-04

18,611 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