#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

#14 in #partial-ord

Download history 4353/week @ 2024-11-16 3867/week @ 2024-11-23 3779/week @ 2024-11-30 4593/week @ 2024-12-07 7655/week @ 2024-12-14 4243/week @ 2024-12-21 4748/week @ 2024-12-28 6499/week @ 2025-01-04 10403/week @ 2025-01-11 7822/week @ 2025-01-18 6491/week @ 2025-01-25 9951/week @ 2025-02-01 11146/week @ 2025-02-08 12504/week @ 2025-02-15 10569/week @ 2025-02-22 6808/week @ 2025-03-01

42,691 downloads per month
Used in 27 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