use std::ops::{Add,Mul}; use crate::ratio::Ratio; use fixed_wide_traits::wide::{WideMul,WideDiv}; impl Ratio { pub fn rational_add(self,rhs:T)->Ratio<>::Output>>::Output,Den> where Den:Mul, Num:Add<>::Output>, { Ratio{ num:self.num+self.den.mul(rhs), den:self.den, } } pub fn wide_rational_add(self,rhs:T)->Ratio<>::Output>>::Output,Den> where Den:WideMul, Num:Add<>::Output>, { Ratio{ num:self.num+self.den.wide_mul(rhs), den:self.den, } } } impl WideMul for Ratio where Num:WideMul, { type Output=Ratio<>::Output,Den>; fn wide_mul(self,rhs:T)->Ratio<>::Output,Den>{ Ratio{ num:self.num.wide_mul(rhs), den:self.den, } } } impl WideDiv for Ratio where Den:WideMul, { type Output=Ratio>::Output>; fn wide_div(self,rhs:T)->Ratio>::Output>{ Ratio{ num:self.num, den:self.den.wide_mul(rhs), } } }