From e9c32da93b992f3ea0d19e4853b5ff1dd237956a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 21 Mar 2025 22:17:43 +0100 Subject: [PATCH] Make trait implementations a bit less dense --- crates/fj-math/src/scalar.rs | 50 ++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/crates/fj-math/src/scalar.rs b/crates/fj-math/src/scalar.rs index feb0182f5..1c89648f2 100644 --- a/crates/fj-math/src/scalar.rs +++ b/crates/fj-math/src/scalar.rs @@ -218,7 +218,10 @@ impl ops::Neg for Scalar { } } -impl> ops::Add for Scalar { +impl ops::Add for Scalar +where + T: Into, +{ type Output = Self; fn add(self, rhs: T) -> Self::Output { @@ -226,7 +229,10 @@ impl> ops::Add for Scalar { } } -impl> ops::Sub for Scalar { +impl ops::Sub for Scalar +where + T: Into, +{ type Output = Self; fn sub(self, rhs: T) -> Self::Output { @@ -234,7 +240,10 @@ impl> ops::Sub for Scalar { } } -impl> ops::Mul for Scalar { +impl ops::Mul for Scalar +where + T: Into, +{ type Output = Self; fn mul(self, rhs: T) -> Self::Output { @@ -242,7 +251,10 @@ impl> ops::Mul for Scalar { } } -impl> ops::Div for Scalar { +impl ops::Div for Scalar +where + T: Into, +{ type Output = Self; fn div(self, rhs: T) -> Self::Output { @@ -250,7 +262,10 @@ impl> ops::Div for Scalar { } } -impl> ops::Rem for Scalar { +impl ops::Rem for Scalar +where + T: Into, +{ type Output = Self; fn rem(self, rhs: T) -> Self::Output { @@ -258,35 +273,50 @@ impl> ops::Rem for Scalar { } } -impl> ops::AddAssign for Scalar { +impl ops::AddAssign for Scalar +where + T: Into, +{ fn add_assign(&mut self, rhs: T) { self.value.add_assign(rhs.into().value); *self = self.value.into(); } } -impl> ops::SubAssign for Scalar { +impl ops::SubAssign for Scalar +where + T: Into, +{ fn sub_assign(&mut self, rhs: T) { self.value.sub_assign(rhs.into().value); *self = self.value.into(); } } -impl> ops::MulAssign for Scalar { +impl ops::MulAssign for Scalar +where + T: Into, +{ fn mul_assign(&mut self, rhs: T) { self.value.mul_assign(rhs.into().value); *self = self.value.into(); } } -impl> ops::DivAssign for Scalar { +impl ops::DivAssign for Scalar +where + T: Into, +{ fn div_assign(&mut self, rhs: T) { self.value.div_assign(rhs.into().value); *self = self.value.into(); } } -impl> ops::RemAssign for Scalar { +impl ops::RemAssign for Scalar +where + T: Into, +{ fn rem_assign(&mut self, rhs: T) { self.value.rem_assign(rhs.into().value); *self = self.value.into();