compare with From types

This commit is contained in:
Quaternions 2024-09-10 11:14:12 -07:00
parent e66a245c78
commit c20a0a4a89

View File

@ -52,6 +52,15 @@ impl<const N:usize,const F:usize> PartialEq for Fixed<N,F>{
self.bits.eq(&other.bits)
}
}
impl<const N:usize,const F:usize,T> PartialEq<T> for Fixed<N,F>
where
T:Copy,
BInt::<N>:From<T>,
{
fn eq(&self,&other:&T)->bool{
self.bits.eq(&other.into())
}
}
impl<const N:usize,const F:usize> Eq for Fixed<N,F>{}
impl<const N:usize,const F:usize> PartialOrd for Fixed<N,F>{
@ -59,6 +68,15 @@ impl<const N:usize,const F:usize> PartialOrd for Fixed<N,F>{
self.bits.partial_cmp(&other.bits)
}
}
impl<const N:usize,const F:usize,T> PartialOrd<T> for Fixed<N,F>
where
T:Copy,
BInt::<N>:From<T>,
{
fn partial_cmp(&self,&other:&T)->Option<std::cmp::Ordering>{
self.bits.partial_cmp(&other.into())
}
}
impl<const N:usize,const F:usize> Ord for Fixed<N,F>{
fn cmp(&self,other:&Self)->std::cmp::Ordering{
self.bits.cmp(&other.bits)