Crate uom [] [src]

Units of measurement is a crate that does automatic type-safe zero-cost dimensional analysis. You can create your own systems or use the pre-built International System of Units (SI) which is based on the International System of Quantities (ISQ) and includes numerous quantities (length, mass, time, ...) with conversion factors for even more numerous measurement units (meter, kilometer, foot, mile, ...). No more crashing your climate orbiter!

The simple example below shows how to use quantities and units as well as how uom stops invalid operations

extern crate uom;

use uom::si::f32::*;
use uom::si::length::kilometer;
use uom::si::time::second;

fn main() {
    let length = Length::new(5.0, kilometer);
    let time = Time::new(15.0, second);
    let velocity = length / time;
    //let error = length + time; // error[E0308]: mismatched types
}

See examples provided with the crate for more advanced usage including how to create Quantity type aliases for a different set of base units and how to create an entirely new system.

Modules

si

International System of Units (SI) and International System of Quantities (ISQ) implementations.

Macros

ISQ

Macro to implement quantity type aliases for a specific system of units and value storage type.

prefix

Macro to implement the SI prefixes for multiples of units and submultiples of units.

quantity

Macro to implement a quantity and associated measurement units. Note that this macro must be executed in direct submodules of the module where the system! macro was executed.

system

Macro to implement a system of quantities.