Function map_range

Source
pub fn map_range<N, M>(value: N, _: Range<N>, _: Range<M>) -> M
where N: Num + NumCast + Copy + PartialOrd + Debug, M: Num + NumCast + Copy + PartialOrd + Debug,
Expand description

Map a value from one range to another range.

§Example

let x = map_range(5, 0..10, 0..100);
assert_eq!(x, 50);

let y = map_range(3, 2..5, 0..3);
assert_eq!(y, 1);

§Panics

Panics if the given value is outside the input range, if in_low >= in_high, or if out_low >= out_high, or if number conversions fail.