Function core::cmp::partial_max
[−]
[src]
pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T>
Deprecated since 1.3.0
: has not proven itself worthwhile
Compare and return the maximum of two values if there is one.
Returns the second argument if the comparison determines them to be equal.
Examples
#![feature(cmp_partial)] fn main() { use std::cmp; assert_eq!(Some(2), cmp::partial_max(1, 2)); assert_eq!(Some(2), cmp::partial_max(2, 2)); }#![feature(cmp_partial)] use std::cmp; assert_eq!(Some(2), cmp::partial_max(1, 2)); assert_eq!(Some(2), cmp::partial_max(2, 2));
When comparison is impossible:
#![feature(cmp_partial)] fn main() { use std::cmp; let result = cmp::partial_max(std::f64::NAN, 1.0); assert_eq!(result, None); }#![feature(cmp_partial)] use std::cmp; let result = cmp::partial_max(std::f64::NAN, 1.0); assert_eq!(result, None);