num::traits

Function clamp

Source
pub fn clamp<T>(input: T, min: T, max: T) -> T
where T: PartialOrd,
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).