Fix trait

This commit is contained in:
Quaternions 2024-09-16 15:02:31 -07:00
parent 0734122e75
commit a100f182e1

View File

@ -493,6 +493,10 @@ macro_repeated!(
(1,15)
);
pub trait Fix<Out>{
fn fix(self)->Out;
}
macro_rules! impl_fix_rhs_lt_lhs_not_const_generic{
(
(),
@ -507,6 +511,13 @@ macro_rules! impl_fix_rhs_lt_lhs_not_const_generic{
}
}
}
impl Fix<Fixed<$rhs,{$rhs*32}>> for Fixed<$lhs,{$lhs*32}>{
fn fix(self)->Fixed<$rhs,{$rhs*32}>{
paste::item!{
self.[<fix_ $rhs>]()
}
}
}
}
}
macro_rules! impl_fix_lhs_lt_rhs_not_const_generic{
@ -523,6 +534,13 @@ macro_rules! impl_fix_lhs_lt_rhs_not_const_generic{
}
}
}
impl Fix<Fixed<$rhs,{$rhs*32}>> for Fixed<$lhs,{$lhs*32}>{
fn fix(self)->Fixed<$rhs,{$rhs*32}>{
paste::item!{
self.[<fix_ $rhs>]()
}
}
}
}
}
macro_rules! impl_fix_lhs_eq_rhs_not_const_generic{
@ -539,6 +557,13 @@ macro_rules! impl_fix_lhs_eq_rhs_not_const_generic{
}
}
}
impl Fix<Fixed<$rhs,{$rhs*32}>> for Fixed<$lhs,{$lhs*32}>{
fn fix(self)->Fixed<$rhs,{$rhs*32}>{
paste::item!{
self.[<fix_ $rhs>]()
}
}
}
}
}