forked from iliekturtles/uom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.rs
24 lines (19 loc) · 767 Bytes
/
base.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Example showing how to create a set of `Quantity` type aliases for a different set of base
//! units.
#[macro_use]
extern crate uom;
use uom::si::length::{centimeter, meter};
use uom::si::time::second;
mod cgs {
ISQ!(uom::si, f32, (centimeter, gram, second, ampere, kelvin, mole, candela));
}
fn main() {
let l1 = uom::si::f32::Length::new::<meter>(1.0);
let l2 = cgs::Length::new::<centimeter>(1.0);
let t1 = uom::si::f32::Time::new::<second>(15.0);
println!("{}: {:?}", uom::si::length::description(), l1);
println!("{}: {:?}", uom::si::length::description(), l2);
println!("{:?} + {:?} = {:?}", l1, l2, (l1 + l2));
println!("{:?} + {:?} = {:?}", l2, l1, (l2 + l1));
println!("{:?} / {:?} = {:?}", l2, t1, (l2 / t1));
}