play.rust-lang.orgRust PlaygroundA browser interface to the Rust compiler to experiment with the language
Did you know that a lot of things in #Rust directly implement the `Ord` trait?
For example `Option<T>` where T: Ord
https://doc.rust-lang.org/std/option/enum.Option.html#impl-Ord-for-Option%3CT%3E
So you can do:
assert_eq(max(Some(0), Some(1)), Some(1))
assert_eq(max(Some(0), None), Some(0))
assert_eq(min(Some(0), None), None)
There are a lot of other things that implement `Ord`:
https://doc.rust-lang.org/std/cmp/trait.Ord.html#implementors