练习:通用 min 函数

In this short exercise, you will implement a generic min function that determines the minimum of two values, using the Ord trait.

1. use std::cmp::Ordering;

3. // TODO: implement the `min` function used in `main`.

5. fn main() {
6. assert_eq!(min(0, 10), 0);
7. assert_eq!(min(500, 123), 123);

9. assert_eq!(min('a', 'z'), 'a');
10. assert_eq!(min('7', '1'), '1');

12. assert_eq!(min("hello", "goodbye"), "goodbye");
13. assert_eq!(min("bat", "armadillo"), "armadillo");
14. }

This slide and its sub-slides should take about 10 minutes.