Added trait From<T> for Ratio<T> where T: Clone + Integer

This commit is contained in:
Wictor Lund 2016-12-01 21:37:07 +02:00
parent be61427d03
commit de91d5d9e3
1 changed files with 7 additions and 0 deletions

View File

@ -261,6 +261,13 @@ impl Ratio<BigInt> {
}
}
// From integer
impl<T> From<T> for Ratio<T> where T: Clone + Integer {
fn from(x: T) -> Ratio<T> {
Ratio::from_integer(x)
}
}
// Comparisons
// Mathematically, comparing a/b and c/d is the same as comparing a*d and b*c, but it's very easy