[][src]Macro yaum::convert_unit

macro_rules! convert_unit {
    ($from:ty, $to: ty, $factor: expr) => { ... };
}

Specify the conversion factor between two types.

Example

#[macro_use] extern crate yaum;
use yaum::*;
use yaum::time::*;

yaum::impl_unit!(BitSize, {
    b: 1.0,
    kb: 1024.0,
    Mb: 1024.0 * 1024.0
});

yaum::impl_unit!(ByteSize, {
    B: 1.0,
    kB: 1024.0,
    MB: 1024.0 * 1024.0
});

// define conversion between the two units (1 byte = 8 bits):
yaum::convert_unit!(ByteSize, BitSize, 8.0);