Function core::cmp::partial_min
[−]
[src]
pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T>
Unstable
Compare and return the minimum of two values if there is one.
Returns the first argument if the comparison determines them to be equal.
Examples
#![feature(core)] extern crate core; fn main() { use std::cmp; assert_eq!(Some(1), cmp::partial_min(1, 2)); assert_eq!(Some(2), cmp::partial_min(2, 2)); }use std::cmp; assert_eq!(Some(1), cmp::partial_min(1, 2)); assert_eq!(Some(2), cmp::partial_min(2, 2));
When comparison is impossible:
#![feature(core)] extern crate core; fn main() { use std::cmp; let result = cmp::partial_min(std::f64::NAN, 1.0); assert_eq!(result, None); }use std::cmp; let result = cmp::partial_min(std::f64::NAN, 1.0); assert_eq!(result, None);