[][src]Macro uom::quantity

macro_rules! quantity {
    (
        $(#[$quantity_attr:meta])* quantity: $quantity:ident; $description:expr;
        $(#[$dim_attr:meta])* dimension: $system:ident<$($dimension:ident),+>;
        $(kind: $kind:ty;)?
        units {
            $($(#[$unit_attr:meta])* @$unit:ident: $($conversion:expr),+; $abbreviation:expr,
                $singular:expr, $plural:expr;)+
        }
    ) => { ... };
    (@kind $kind:ty) => { ... };
    (@kind) => { ... };
}

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. @... match arms are considered private.

An example invocation is given below for the quantity of length in a meter-kilogram-second system. The #[macro_use] attribute must be used when including the uom crate to make the quantity! macro available.

#[macro_use]
extern crate uom;

#[macro_use]
mod length {
    quantity! {
        /// Length (base unit meter, m).
        quantity: Length; "length";
        /// Length dimension, m.
        dimension: Q<P1 /*length*/, Z0 /*mass*/, Z0 /*time*/>;
        units {
            @meter: 1.0E0; "m", "meter", "meters";
            @foot: 3.048E-1; "ft", "foot", "feet";
        }
    }
}