clamp

Function clamp 

Source
pub fn clamp<T>(value: T, min_val: T, max_val: T) -> T
where T: PartialOrd,
Expand description

Clamps a value to a specified minimum and maximum range.

ยงExamples

use khora_core::math::clamp;
assert_eq!(clamp(1.5, 0.0, 1.0), 1.0);
assert_eq!(clamp(-1.0, 0.0, 1.0), 0.0);
assert_eq!(clamp(0.5, 0.0, 1.0), 0.5);