macro up wide traits
This commit is contained in:
parent
ac250e9d84
commit
e604ce83e9
@ -1,6 +1,6 @@
|
||||
use std::ops::{Add,Mul};
|
||||
use crate::ratio::Ratio;
|
||||
use fixed_wide_traits::wide::{WideMul,WideDiv};
|
||||
use fixed_wide_traits::wide::{WideMul,WideDiv,WideDot,WideCross};
|
||||
|
||||
impl<Num,Den:Copy> Ratio<Num,Den>
|
||||
{
|
||||
@ -25,18 +25,25 @@ impl<Num,Den:Copy> Ratio<Num,Den>
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<Num,Den,T> WideMul<T> for Ratio<Num,Den>
|
||||
where
|
||||
Num:WideMul<T>,
|
||||
{
|
||||
type Output=Ratio<<Num as WideMul<T>>::Output,Den>;
|
||||
fn wide_mul(self,rhs:T)->Ratio<<Num as WideMul<T>>::Output,Den>{
|
||||
Ratio{
|
||||
num:self.num.wide_mul(rhs),
|
||||
den:self.den,
|
||||
macro_rules! impl_mul_operator {
|
||||
($struct:ident,$trait:ident,$method:ident)=>{
|
||||
impl<Num,Den,Rhs> $trait<Rhs> for $struct<Num,Den>
|
||||
where
|
||||
Num:$trait<Rhs>,
|
||||
{
|
||||
type Output=$struct<<Num as $trait<Rhs>>::Output,Den>;
|
||||
fn $method(self,rhs:Rhs)->Self::Output{
|
||||
$struct{
|
||||
num:self.num.$method(rhs),
|
||||
den:self.den,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
impl_mul_operator!(Ratio,WideMul,wide_mul);
|
||||
impl_mul_operator!(Ratio,WideDot,wide_dot);
|
||||
impl_mul_operator!(Ratio,WideCross,wide_cross);
|
||||
impl<Num,Den,T> WideDiv<T> for Ratio<Num,Den>
|
||||
where
|
||||
Den:WideMul<T>,
|
||||
|
Loading…
Reference in New Issue
Block a user