8 releases

0.9.3 Oct 30, 2024
0.9.2 Oct 28, 2024
0.2.6 Oct 11, 2024

#5 in #si

Download history 452/week @ 2024-10-09 9/week @ 2024-10-16 310/week @ 2024-10-23 212/week @ 2024-10-30

537 downloads per month

LGPL-3.0-only

180KB
8K SLoC

SITY for SI (Intenational System Unit) Typing

This library makes SI types available in Rust. International System Conformance is checked at compile time.

Example

pub use sity::*;
use std::mem;

fn main() {
    let a = centi_metre(3.0);
    let b = centi_metre(4.0);
    let c = second(2.0);
    let si_value = a * b / c;
    let si_value_size = mem::size_of_val(&si_value);
    // let x = a + c; // Compile time Error

    println!("si_value = {} (size = {})", si_value, si_value_size);
    let pure_value = si_value.value();
    let pure_value_size = mem::size_of_val(&pure_value);
    println!("pure_value = {} (size = {})", pure_value, pure_value_size);    
}

Dependencies

~2MB
~42K SLoC