Function std::ops::cmp

Overview
fn cmp(lhs: any, rhs: any) -> Ordering

Perform a total comparison over two values.

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

Panics

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

use std::ops::cmp;

let _ = cmp(1.0, f64::NAN);

Examples

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

assert_eq!(cmp(1, 1), Ordering::Equal);
assert_eq!(cmp(1, 2), Ordering::Less);