1 stable release
new 1.1.0 | Apr 6, 2025 |
---|
#13 in #ratio
13KB
238 lines
This crate provides compile-time rational arithmetic support in Rust with const functions and const generics. It can be used to specify measurement units for numbers.
Note that this crate relies on the incomplete generic_const_exprs feature. Please, use with caution.
Compile-time rational arithmetic in Rust
The ct_ratio
provides compile-time arithmetic in Rust using const functions and const generics. An example of such code:
type A = Ratio<1, 2>;
type B = Ratio<1, 3>;
type C = <RationalSum<A,B> as StaticArithmetic>::OpResult; // This type will be equal to Ratio<5, 6>
This code relies on a feature generic_const_exprs that is currently (at the README writing time) is considered incomplete. Please, use with caution.