From a100f182e17a73eba8fe7e21d0baf722ecf3936b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 16 Sep 2024 15:02:31 -0700 Subject: [PATCH] Fix trait --- fixed_wide/src/fixed.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index c0751e1..37253a7 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -493,6 +493,10 @@ macro_repeated!( (1,15) ); +pub trait Fix{ + 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> for Fixed<$lhs,{$lhs*32}>{ + fn fix(self)->Fixed<$rhs,{$rhs*32}>{ + paste::item!{ + self.[]() + } + } + } } } 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> for Fixed<$lhs,{$lhs*32}>{ + fn fix(self)->Fixed<$rhs,{$rhs*32}>{ + paste::item!{ + self.[]() + } + } + } } } 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> for Fixed<$lhs,{$lhs*32}>{ + fn fix(self)->Fixed<$rhs,{$rhs*32}>{ + paste::item!{ + self.[]() + } + } + } } }