Show HN: A brand new, stable, no_std, extendable, Rust units library

crates.io

1 points by pengavin 12 hours ago

Over the past few weeks I have been working on a new units library called Shrewnit! My motivation for this library was the amount of unstable or very recent features used by existing units libraries such as uom or diman. Not only Shrewnit should be usable on very old toolchain versions, it is also usable on embedded platforms without std, an allocator, or floating point operations.

Shrewnit also provides APIs for extending existing dimensions with new units, or adding new dimensions entirely.

Units can be created in two ways: ```rust // Multiplication: let quantity: Length<f32> = 1.0 * Inches; let quantity = 1.0f32 * Inches;

    // Extension trait:
    let quantity: Length<f32> = 1.0.inches();
    let quantity = 1.0f32.inches();
``` Unit math works as you would expect: ```rust let velocity = 12.0f64 * MetersPerSecond; let time = 3.0 * Seconds;

    let displacement = velocity * time;
    
    println!("{}", displacement.to::<Inches>());
```