Crate measurement_units

Source
Expand description

§measurement_units

measurement_units is a rust library for basic measurements units conversion such as length, mass, time, volume, percents.

§Examples

use measurement_units::{convert, Length};
let length_in_centimeters = convert(&1.0, &Length::M, &Length::CM, &Option::None);
assert_eq!(100.0, length_in_centimeters);

let length_in_meters = convert(&99.5, &Length::CM, &Length::M, &Some(0_u32));
assert_eq!(1.0, length_in_meters);

Enums§

Length
Measurement units for length.
Mass
Measurement units for mass.
Percent
Measurement units for percent to convert it to the decimal value and vice-versa.
Time
Measurement units for time.
Volume
Measurement units for volume.

Traits§

Convertable
Main trait implements list of conversion coefficients for measurement units.

Functions§

convert
Converts measurement unit from one to another using coefficients specified by the Convertable trait in the conversion_coefficient method. Precision argument defines number of decimal digits to roundup the result.