Trait dimensioned::traits::Map
[−]
[src]
pub trait Map<ValueOut>: Dimensionless { type Output; fn map<F: FnOnce(Self::Value) -> ValueOut>(self, f: F) -> Self::Output; }
Perform an operation on the contained value.
This trait is only defined for unitless types, and it keeps them unitless, so it is perfectly safe to use.
It can be used similarly to MapUnsafe
, but only for Dimensionless
quantities, and it cannot
make them non-Dimensionless
.
Example
extern crate dimensioned as dim; fn main() { use dim::si; let x1 = 2.0 * si::ONE; let x2 = 2.0f64; use dim::Map; assert_eq!(x1.map(|v| v.sin()), x2.sin() * si::ONE); }
Associated Types
type Output
The type to which the input is mapped
Required Methods
Implementors
impl<ValueIn, ValueOut> Map<ValueOut> for dimensioned::unit_systems::si::Unitless<ValueIn>
impl<ValueIn, ValueOut> Map<ValueOut> for dimensioned::unit_systems::ucum::Unitless<ValueIn>
impl<ValueIn, ValueOut> Map<ValueOut> for dimensioned::unit_systems::mks::Unitless<ValueIn>
impl<ValueIn, ValueOut> Map<ValueOut> for dimensioned::unit_systems::cgs::Unitless<ValueIn>
impl<ValueIn, ValueOut> Map<ValueOut> for dimensioned::unit_systems::fps::Unitless<ValueIn>