Calculates the maximum of two values by mutable reference.
fn max_mut<T>(one: &'a mut T, two: &'a mut T) -> &'a mut 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 = &mut 1; let y = &mut 2; *max(x, y) = 3; assert!(*y == 3);