Function ::std::ops::partial_cmp

Overview
fn partial_cmp(lhs, rhs) -> Option

Perform a partial comparison over two values.

This produces the same behavior as when comparison operators like less than (<) is used.

For non-builtin types this leans on the behavior of the [PARTIAL_CMP] protocol.

Panics

Panics if we're trying to compare two values which are not comparable.

Examples

use std::ops::partial_cmp;
use std::cmp::Ordering;

assert_eq!(partial_cmp(1.0, 1.0), Some(Ordering::Equal));
assert_eq!(partial_cmp(1.0, 2.0), Some(Ordering::Less));
assert_eq!(partial_cmp(1.0, f64::NAN), None);