[−][src]Crate mag
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 mag::{length::{ft, m, mi}, time::{h, s}}; let a = 1.0 * ft; // Length<ft> let b = a.to::<m>(); // 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!(a.to_string(), "1 ft"); assert_eq!(b.to_string(), "0.3048 m"); assert_eq!(c.to_string(), "30 s"); assert_eq!(d.to_string(), "60 ㎐"); assert_eq!(e.to_string(), "55 mi/h");
Room For Improvement
- Small set of quantities and units implemented
- Quantities are f64 only
Modules
length | Base units of length. |
temp | Base units of temperature. |
time | Base units of time. |
Structs
Area | A measurement of physical area. |
Frequency | A measurement of temporal frequency for repeating events. |
Length | A measurement of physical length, distance or range. |
Period | A measurement of period, duration or interval of time. |
Speed | A measurement of speed. |
Temperature | A measurement of thermodynamic temperature. |
Volume | A measurement of physical volume. |