num_traits

Function clamp_max

Source
pub fn clamp_max<T: PartialOrd>(input: T, max: T) -> T
Expand description

A value bounded by a maximum value

If input is greater than max then this returns max. Otherwise this returns input. clamp_max(std::f32::NAN, 1.0) preserves NAN different from f32::max(std::f32::NAN, 1.0).

Panics in debug mode if !(max == max). (This occurs if max is NAN.)