Use std::cmp::Ordering with the .cmp() method to compare two values and handle the result with a match statement. This pattern determines if the first value is less than, greater than, or equal to the second.
use std::cmp::Ordering;
fn main() {
let a = 5;
let b = 10;
match a.cmp(&b) {
Ordering::Less => println!("{a} is less than {b}"),
Ordering::Greater => println!("{a} is greater than {b}"),
Ordering::Equal => println!("{a} is equal to {b}"),
}
}