Unit Converter
usage
to import this library use
use unit_converter_lib;
to read the stored value from a unit use .0
examples
convert 5 meters into inches
// import types
use length;
// create a variable that stores 5 meters
let meters: M = M;
// convert the 5 meters to inches
let converted_result = INCH from;
// load the float value from the unit
let converted_result_as_float = converted_result.0;
get unit by name and save it in a unit container, after that we convert it to meters
use length;
// get the unit by it's name
let unit_type: UNITS = UNITS by_name;
let value: f64 = 5.0;
// create a unit container with a specified unit and value
let unit_container = new;
// convert the unit
let converted_result_as_float = from.0;
how to create a unit
use unit_converter_lib::units;
let unit = units::<unit type>::<unit>(<value as f64>);
= length|mass|volume|speed|temperature
how to create a unit container
version 1
use unit_converter_lib::units;
let unit_type = units::<unit type>::UNITS::<unit>;
let uc = units::<unit type>::UnitContainer::new(unit_type, <value>);
= length|mass|volume|speed|temperature
version 2
use unit_converter_lib::units;
let uc = units::<unit type>::UnitContainer::<unit>(units::<unit type>::<unit>(<value>));
= length|mass|volume|speed|temperature
source for conversion rates
https://www.isa.org/getmedia/5be3daca-5c44-4d9e-bf1c-a4aa55cfb759/CCST-Conversions-document.pdf