Mag is a library for dealing with physical quantities and units.
Quantities are created by multiplying scalar values by a unit type. These units are named after common abbreviations:
use ;
let a = 1.0 * ft; // Length<ft>
let b = a.; // convert to Length<m>
let c = 30 * s; // Period<s>
let d = 60.0 / s; // Frequency<s>
let e = 55.0 * mi / h; // Speed<mi, h>
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Highlights
- Easy to understand and use
- No external dependencies
- Fast compile time
- Units are not discarded when creating quantities
Alternative
If mag doesn't fit your needs, you could try the uom crate, which has many more features.