We effectively restrict the type of Ratios by only impling new() and new_raw() on T: Clone + Integer. This appears to work well, but putting the same restrictions on the T in the Ratio declaration itself would make this requirement more explicit.
e.g.
/// Represents the ratio between two numbers.
#[derive(Copy, Clone, Debug)]
#[allow(missing_docs)]
pub struct Ratio<T: Clone + Integer> {
/// Numerator.
numer: T,
/// Denominator.
denom: T,
}
Testing out this change now, the compiler complains for every method in this library that uses Ratio where T is not Clone and Integer (for example Display).
Unlike many of the issues I have been submitting recently, I believe this would not be a breaking change.
We effectively restrict the type of Ratios by only
implingnew()andnew_raw()onT: Clone + Integer. This appears to work well, but putting the same restrictions on theTin theRatiodeclaration itself would make this requirement more explicit.e.g.
Testing out this change now, the compiler complains for every method in this library that uses Ratio where T is not
CloneandInteger(for exampleDisplay).Unlike many of the issues I have been submitting recently, I believe this would not be a breaking change.