Crate ct_ratio

Source
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 Ratio types may represent the same number. You can use the Reduced type alias from the Reducible trait to reduce the number to the lowest terms
RationalCmp
Helper type for comparing two compile time rational constants
RationalDiff
Helper type for substracting one rational constant from another
RationalDiv
Helper type for dividing one rational constant by another
RationalProduct
Helper type for multiplying two compile time rational constants
RationalSum
Helper type for adding up two compile time rational constants

Traits§

Reducible
A trait to reduce compile-time rational constants
StaticArithmetic
A trait to obtain results of compile-time rational arithmetic operations
StaticRatio
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