use ferrunitas::Unit;
use ferrunitas::typenum_consts::*;
use ferrunitas::{prefix, quantity, unit};
quantity!(Length: M Z0, L P1, T Z0, I Z0, Th Z0, N Z0, J Z0);
quantity!(Time: M Z0, L Z0, T P1, I Z0, Th Z0, N Z0, J Z0);
quantity!(Velocity: [(Length, P1), (Time, N1)]);
quantity!(Velocity2: M Z0, L P1, T N1, I Z0, Th Z0, N Z0, J Z0; marked);
prefix!(Milli, 1e-3, "m");
prefix!(Kilo, 1e3, "k");
unit!(base: Metre, "m", Length; prefixable);
unit!(base: Second, "s", Time; prefixable);
unit!(prefix: Kilometre, Kilo, Metre);
unit!(prefix: Millisecond, Milli, Second);
unit!(derived: Foot, "ft", (0.3048, Metre));
unit!(derived: Mile, "mi", (5280, Foot));
unit!(derived: Hour, "h", (3600, Second));
unit!(compound: MetrePerSecond, "m/s", [(Metre, P1), (Second, N1)]);
unit!(compound: KilometrePerHour, "km/h", [(Kilometre, P1), (Hour, N1)]);
unit!(compound: YardsPerMinute, "yd/min", [(3, Foot, P1), (60, Second, N1)]);
unit!(base: MetrePerSecond2, "m/s", Velocity2);
unit!(compound: KilometrePerHour2, "km/h", [(Kilometre, P1), (Hour, N1)]; marked Velocity2);
fn main() {
let length = Foot::new(500.0);
let time = Second::new(90.0);
let speed = length / time;
println!(
"{:.2} in {:.2} equal a speed of {:.2} or {:.2}",
length,
time,
speed.as_measure::<KilometrePerHour>(),
speed.as_measure::<YardsPerMinute>()
);
}