Expand description
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.
Structs§
- Ratio
- A type that represents a rational compile-time constant. This is a zero-sized type that’s intended to be used for generics.
Please note that two distict
Ratiotypes may represent the same number. You can use theReducedtype alias from theReducibletrait to reduce the number to the lowest terms - Rational
Cmp - Helper type for comparing two compile time rational constants
- Rational
Diff - Helper type for substracting one rational constant from another
- Rational
Div - Helper type for dividing one rational constant by another
- Rational
Product - Helper type for multiplying two compile time rational constants
- Rational
Sum - Helper type for adding up two compile time rational constants
Traits§
- Reducible
- A trait to reduce compile-time rational constants
- Static
Arithmetic - A trait to obtain results of compile-time rational arithmetic operations
- Static
Ratio - A trait for rational compile-time constants that can be used as a trait bound for generics.
Functions§
- gcd
- Finds the greatest common divisor using the Euclidean algorithm