explicitly implement From for specific types
This commit is contained in:
parent
46bb2bac4e
commit
c4a2778af1
@ -70,15 +70,22 @@ impl<const F:usize> Fixed<1,F>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const N:usize,const F:usize,T> From<T> for Fixed<N,F>
|
macro_rules! impl_from {
|
||||||
where
|
($($from:ty),*)=>{
|
||||||
BInt<N>:From<T>
|
$(
|
||||||
{
|
impl<const N:usize,const F:usize> From<$from> for Fixed<N,F>{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(value:T)->Self{
|
fn from(value:$from)->Self{
|
||||||
Self::from_bits(BInt::<{N}>::from(value)<<F as u32)
|
Self::from_bits(BInt::<{N}>::from(value)<<F as u32)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
impl_from!(
|
||||||
|
u8,u16,u32,u64,u128,usize,
|
||||||
|
i8,i16,i32,i64,i128,isize
|
||||||
|
);
|
||||||
|
|
||||||
impl<const N:usize,const F:usize> PartialEq for Fixed<N,F>{
|
impl<const N:usize,const F:usize> PartialEq for Fixed<N,F>{
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user