Mag is a library for dealing with units of measure. Magnitude!
Highlights
- Easy to understand and use
- No external dependencies
- Fast compile time
- Units are not discarded when creating quantities
Example
use ;
let a = 1.0 * ft; // Length<ft>
let b = a.; // convert to Length<m>
let c = 30.0 * 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!;
Room For Improvement
- Small set of quantities and units implemented
- Quantities are f64 only
Alternatives
There are similar crates out there. Here is a partial list:
- uom
- dimensioned
- yaiouom
- measurements
- simple_units
- metric
- unit
- Plus many more!