Function num_traits::clamp

source ·
pub fn clamp<T: PartialOrd>(input: T, min: T, max: T) -> T
Expand description

A value bounded by a minimum and a maximum

If input is less than min then this returns min. If input is greater than max then this returns max. Otherwise this returns input.

Panics in debug mode if !(min <= max).