Function lrs::cmp::max_ref

Calculates the maximum of two values by reference.

Syntax

fn max_ref<T>(one: &'a T, two: &'a T) -> &'a 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 = &1;
let y = &2;
assert!(max(x, y) == y);

See also