simple-si-units

GitHub Workflow Build Status GitHub Workflow Test Status Crate.io Redistribution license

This Rust library provides compiler-checked types for the standard set of SI units, as specified by the US National Institute of Standards and Technology (this project is not officially endorsed by NIST).

What's included?

Units

This crate provides types for the following units. Other kinds of quantities not listed below (eg jolt) are beyond the scope of this crate.

Base SI units (and example unit of measure):

Derived units:

What's NOT included?

Roadmap

The version of this library will be incremented to reflect progress through the various milestones. The goal is to reach version 1.0 (API stable) as quickly as practical.

How it works

For each type of unit (eg Distance), Simple SI Units provides a struct to represent the unit and which implements common type conversion. For example, dividing a Distance by a Time results in a Velocity: rust todo!();

Adding your own units

Simple SI Units does not provide an exhaustive list of possible units of measure. To create your own units, use the Unit procedural macro and UnitData trait bundle, like this:

```rust use simplesiunits::{Unit, UnitData};

[derive(Unit, Debug, Copy, Clone)]

struct HyperVelocity{ squaremetersper_second: T }

fn weighted_sum(a: HyperVelocity, b: HyperVelocity, weight: f64) -> HyperVelocity where T:UnitData + From { return weighta + (1.-weight)b; } ```

License

This library is open source, licensed under the Mozilla Public License version 2.0. In summary, you may include this source code as-is in both open-source and proprietary projects without requesting permission from me, but if you modify the source code from this library then you must make your modified version of this library available under an open-source license.