Search
Items tagged with: RustTip
Did you know that a lot of things in #Rust directly implement the `Ord` trait?
For example `Option<T>` where T: Ord
doc.rust-lang.org/std/option/e…
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`:
doc.rust-lang.org/std/cmp/trai…