Function std::cmp::partial_maxUnstable [-] [+] [src]

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

Compare and return the maximum of two values if there is one.

Returns the first argument if the comparison determines them to be equal.

Examples

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:

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);