Function lrs::cmp::max_mut

Calculates the maximum of two values by mutable reference.

Syntax

fn max_mut<T>(one: &'a mut T, two: &'a mut T) -> &'a mut T
    where T: Ord<T> + ?Sized,

Arguments

NameDescription
one

The first value.

two

The second value.

Return value

The returns the larger one of the two values.

Remarks

If the comparison of both objects returns that they are equal, the first one is returned.

Examples

let x = &mut 1;
let y = &mut 2;
*max(x, y) = 3;
assert!(*y == 3);

See also