diff --git a/rational/src/lib.rs b/rational/src/lib.rs index 938de46..ae01b2c 100644 --- a/rational/src/lib.rs +++ b/rational/src/lib.rs @@ -261,6 +261,13 @@ impl Ratio { } } +// From integer +impl From for Ratio where T: Clone + Integer { + fn from(x: T) -> Ratio { + 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