Trait Remap

Source
pub trait Remap
where Self: Sized,
{ // Required method fn remap(self, from: Range<Self>, onto: Range<Self>) -> Self; }
Expand description

Represents a type that can be mapped between two ranges.

Required Methods§

Source

fn remap(self, from: Range<Self>, onto: Range<Self>) -> Self

Remap a value from one range to another. A value outside the bounds of one range will be similarly outside the bounds of the other.

assert_eq!(5.remap(-10..10, -100..100), 50);
assert_eq!(0.5.remap(0.0..1.0, -1.0..1.0), 0.0);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Remap for T
where T: Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Copy,