#unit-system #unit #error-message #units #si #dimension

uy

A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages

3 releases

0.1.2 Jul 31, 2023
0.1.1 Jul 31, 2023
0.1.0 Jul 31, 2023

#621 in Science

MIT license

20KB
441 lines

uy

A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages.

Usage

uy not only stores the unit of a value in the typesystem, it also stores the scale within the unit's type itself.

For example, Quantity<f32, si::m> is not the same type as Quantity<f32, si::kilo<si::m>>.

To convert between types like that, call the .convert() method on Quantity.

Example

use uy::{Quantity, si};

fn how_long(
    d: Quantity<f32, si::m>,
    v: Quantity<f32, uy::Div<si::m, si::s>>
) -> Quantity<f32, si::s> {
    d / v
}

Dependencies

~160KB