pub trait Conversion<V> {
    type T: ConversionFactor<V>;

    fn coefficient() -> Self::T { ... }
    fn constant(op: ConstantOp) -> Self::T { ... }
    fn conversion(&self) -> Self::T
    where
        Self: Sized
, { ... } }
Expand description

Trait to identify units which have a conversion factor.

Generic Parameters

  • V: Underlying storage type trait is implemented for.

Required Associated Types

Conversion factor type specific to the underlying storage type.

Provided Methods

Coefficient portion of conversion factor for converting the given unit to the base unit for the quantity: (value * coefficient()) + constant(). Implementation should return the multiplicative identity (Self::T::one()) if no coefficient exists.

Constant portion of conversion factor for converting the given unit to the base unit for the quantity: (value * coefficient()) + constant(). Implementation should return the additive identity (Self::T::zero()) if no constant exists. See ConstantOp documentation for details about parameter use to ensure the method optimizes correctly.

Instance conversion factor.

Default implementation returns the coefficient: Self::coefficient().

Implementations on Foreign Types

Implementors