Module dimensioned::dimensions [] [src]

Marker traits for various dimensions

The traits in this module can be useful for writing code that is generic with regards to unit system, but involves a specific dimension.

Where appropriate, these traits are implemented for the unit systems in this library.

If you find it lacking, please feel free to submit an issue or pull request to add more.

Example

extern crate dimensioned as dim;

use std::ops::Div;
use dim::dimensions::{Length, Time};
use dim::typenum::Quot;

fn speed<L, T>(dist: L, time: T) -> Quot<L, T> where L: Length + Div<T>, T: Time {
    dist / time
}

fn main() {
    use dim::si;

    let x = 3.0 * si::M;
    let t = 2.0 * si::S;
    let v = speed(x, t);

    assert_eq!(v, x/t);

    // Compiler error:
    // speed(x, x);
}

Traits

Acceleration
AmountOfSubstance
Area
Capacitance
Charge
Conductance
Current
ElectricPotential
Energy
Force
Frequency
Inductance
Jerk
Length
LuminousIntensity
MagneticFlux
Mass
Power
Pressure
ReciprocalLength
Resistance
Temperature
Time
Velocity
Volume