Rust. // type T must have the "Ord" trait // so that ">" and "<" operations can be done fn max<T: Ord>(a: &[T]) -> Option<&T> { let mut result = a.first()?; for n in a { if *n > *result { result = &n; } } Some(result) } To simplify tedious and repeated implementation of traits like Debug and Ord, the derive macro can be used to request compilers to generate certain implementations automatically. Derivable traits include: Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord and Hash. See also Extension method Interface (object-oriented programming) Parametric polymorphism UFCS References External links C++ Programming language topics Type theory