-//
-// The rest of the code dosn't change, so we just copy it.
-
-enum SomethingOrNothing<T> {
- Something(T),
- Nothing,
-}
-use self::SomethingOrNothing::{Something,Nothing};
-
-trait Minimum : Copy {
- fn min(a: Self, b: Self) -> Self;
-}
-
-fn vec_min<T: Minimum>(v: Vec<T>) -> SomethingOrNothing<T> {
- let mut min = Nothing;
- for e in v {
- min = Something(match min {
- Nothing => e,
- Something(n) => T::min(n, e)
- });
- }
- min
-}
-
-// `::std::cmp::min` is a way to refer to this function without importing `std`.
-// We could also have done `use std::cmp;` and later called `cmp::min`. Try that!
-impl Minimum for i32 {
- fn min(a: Self, b: Self) -> Self {
- ::std::cmp::min(a, b)
- }
-}