Calculates the maximum of two values by reference.
fn max_ref<T>(one: &'a T, two: &'a T) -> &'a T
where T: Ord<T> + ?Sized,| Name | Description |
|---|---|
| one | The first value. |
| two | The second value. |
The returns the larger one of the two values.
If the comparison of both objects returns that they are equal, the first one is returned.
let x = &1; let y = &2; assert!(max(x, y) == y);