<commit_before>[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)

# simple_units

A simple unit system for Rust.

It allows you to write numeric code that is not only type save but also "unit save".

It works on stable Rust, but unfortunately that means it doesn't scale.
All units (and combination of them) must be written by hand.
Macros help (and maybe some more macro magic can help more) but it is still a lot of work.

For me it already payed off: I found a small bug in an old Fortran program we are using ;-)

So if your favorite unit is missing just let me know.

There already is a better unit system for Rust: [Dimensioned](https://github.com/paholg/dimensioned) but it needs the unstable nightly compiler version.

## Examples:

```rust
extern crate simple_units;
use simple_units::si_units::*;

fn main() {
    let length = Meter(20.72);
    let time = Second(12.39);

    // Resulting type: MeterPerSecond<commit_msg>add a link to another crate<commit_after>[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)

# simple_units

A simple unit system for Rust.

It allows you to write numeric code that is not only type save but also "unit save".

It works on stable Rust, but unfortunately that means it doesn't scale.
All units (and combination of them) must be written by hand.
Macros help (and maybe some more macro magic can help more) but it is still a lot of work.

For me it already payed off: I found a small bug in an old Fortran program we are using ;-)

So if your favorite unit is missing just let me know.

There already is a better unit system for Rust: [Dimensioned](https://github.com/paholg/dimensioned) but it needs the unstable nightly compiler version.

And another one here: [runits](https://github.com/jesse99/runits)

## Examples:

```rust
extern crate simple_units;
use simple_units::si_units::*;

fn main() {
    let length = Meter(20.72);
    let time = Second(12.39);

    // Resulting type: MeterPerSecond
{'fraction_non_alphanumeric': 0.08936595107338992, 'fraction_numerical': 0.008986520219670495, 'mean_word_length': 4.022556390977444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2288075', 'n_tokens_mistral': 609, 'n_tokens_neox': 579, 'n_words': 277}