Scalable

Trait Scalable 

Source
pub trait Scalable {
    // Required method
    fn scale<R: FromF64>(
        self,
        from_low: impl ToF64,
        from_high: impl ToF64,
        to_low: impl ToF64,
        to_high: impl ToF64,
    ) -> R;
}
Expand description

Trait for mapping a value from one scale to another.

Required Methods§

Source

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Map a value from one scale to another. This is equivalent to Arduino map() method: https://www.arduino.cc/reference/en/language/functions/math/map/

§Parameters
  • self: the value to map
  • from_low: the low end of the originating range
  • from_high: the high end of the originating range
  • to_low: the low end of the target range
  • to_high: the high end of the target range
§Returns

The mapped value.

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.

Implementations on Foreign Types§

Source§

impl Scalable for f32

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for f64

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for i8

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for i16

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for i32

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for i64

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for u8

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for u16

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for u32

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Source§

impl Scalable for u64

Source§

fn scale<R: FromF64>( self, from_low: impl ToF64, from_high: impl ToF64, to_low: impl ToF64, to_high: impl ToF64, ) -> R

Implementors§