Function core::cmp::partial_max [] [src]

pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T>
Unstable

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(core)] extern crate core; fn main() { use std::cmp; assert_eq!(Some(2), cmp::partial_max(1, 2)); assert_eq!(Some(2), cmp::partial_max(2, 2)); }
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(core)] extern crate core; fn main() { use std::cmp; let result = cmp::partial_max(std::f64::NAN, 1.0); assert_eq!(result, None); }
use std::cmp;

let result = cmp::partial_max(std::f64::NAN, 1.0);
assert_eq!(result, None);