Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Implement binary '+' operation
- impl Add for Rational {
- type Output = Rational;
- fn add(self, other: Rational) -> Rational {
- let p = self.num * other.denom + other.num * self.denom;
- let q = self.denom * other.denom;
- Rational::new(p, q)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement