#measurement #converter #units #length #volume #time #mass

measurement-units

Rust library for basic measurements units conversion such as length, mass, time, volume, percents

1 unstable release

0.1.1 Jan 16, 2022
0.1.0 Jan 16, 2022

#1739 in Algorithms

Custom license

9KB
218 lines

measurement-units

Rust library for basic measurements units conversion such as length, mass, time, volume, percents.

Install

# Cargo.toml
[dependencies]
measurement-units = "0.1.1"

Usage

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);

License

MIT (c) 2022 Viacheslav Dobromyslov <viacheslav@dobromyslov.ru>


lib.rs:

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);

No runtime deps