Crates.io | eng-units |
lib.rs | eng-units |
version | 0.1.10 |
source | src |
created_at | 2023-02-22 17:14:12.093876 |
updated_at | 2023-11-22 17:08:59.364874 |
description | Engineering unit coversions and calculations. |
homepage | |
repository | https://github.com/fjpereny/eng-units |
max_upload_size | |
id | 791970 |
size | 135,756 |
let quarter_pounder = mass!(0.25, MassUnit::Pound);
assert_eq!(0.25, quarter_pounder.value);
assert_eq!("0.25 lb", quarter_pounder.to_string());
let quarter_pounder = mass!(0.25, MassUnit::Pound);
let royal_with_cheese = quarter_pounder.convert(MassUnit::Kilogram);
assert_eq!("0.11 kg", royal_with_cheese.to_string());
let temp_1 = temperature!(4.0, TemperatureDeltaUnit::C);
let mass_1 = mass!(5.0, MassUnit::Kilogram);
let t_1 = time!(10.0, TimeUnit::Second);
let unit = temp_1 * mass_1 / t_1;
assert_eq!(2.0, unit.value);
assert_eq!("2.00 kg·°C/s", unit.to_string());
let double = 2.0 * unit;
assert_eq!(4.0, double.value);
assert_eq!("4.00 kg·°C/s", double.to_string());
let flip = double.reciprocal();
assert_eq!(0.25, flip.value);
assert_eq!("0.25 s/kg·°C", flip.to_string());
let mass_2 = mass!(10.0, MassUnit::Kilogram);
let canceled_out = flip * mass_2;
assert_eq!(2.50, canceled_out.value);
assert_eq!("2.50 s/°C", canceled_out.to_string());
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.