From: Tomas Wenström Date: Mon, 8 Feb 2021 18:05:49 +0000 (+0100) Subject: Renamed operator impl macro for Point X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=0d75b79ec38b321835c2f3984252f27ff271f8b4;p=kaka%2Frust-sdl-test.git Renamed operator impl macro for Point --- diff --git a/src/common/geometry.rs b/src/common/geometry.rs index ebf122a..3fee2ad 100644 --- a/src/common/geometry.rs +++ b/src/common/geometry.rs @@ -44,7 +44,7 @@ impl Point { } } -macro_rules! point_op { +macro_rules! impl_point_op { ($op:tt, $trait:ident($fn:ident), $trait_assign:ident($fn_assign:ident), $rhs:ident = $Rhs:ty => $x:expr, $y:expr) => { impl> $trait<$Rhs> for Point { type Output = Self; @@ -68,16 +68,16 @@ macro_rules! point_op { } } -point_op!(+, Add(add), AddAssign(add_assign), rhs = Point => rhs.x, rhs.y); -point_op!(-, Sub(sub), SubAssign(sub_assign), rhs = Point => rhs.x, rhs.y); -point_op!(*, Mul(mul), MulAssign(mul_assign), rhs = Point => rhs.x, rhs.y); -point_op!(/, Div(div), DivAssign(div_assign), rhs = Point => rhs.x, rhs.y); -point_op!(+, Add(add), AddAssign(add_assign), rhs = (T, T) => rhs.0, rhs.1); -point_op!(-, Sub(sub), SubAssign(sub_assign), rhs = (T, T) => rhs.0, rhs.1); -point_op!(*, Mul(mul), MulAssign(mul_assign), rhs = (T, T) => rhs.0, rhs.1); -point_op!(/, Div(div), DivAssign(div_assign), rhs = (T, T) => rhs.0, rhs.1); -point_op!(*, Mul(mul), MulAssign(mul_assign), rhs = Dimension => rhs.width, rhs.height); -point_op!(/, Div(div), DivAssign(div_assign), rhs = Dimension => rhs.width, rhs.height); +impl_point_op!(+, Add(add), AddAssign(add_assign), rhs = Point => rhs.x, rhs.y); +impl_point_op!(-, Sub(sub), SubAssign(sub_assign), rhs = Point => rhs.x, rhs.y); +impl_point_op!(*, Mul(mul), MulAssign(mul_assign), rhs = Point => rhs.x, rhs.y); +impl_point_op!(/, Div(div), DivAssign(div_assign), rhs = Point => rhs.x, rhs.y); +impl_point_op!(+, Add(add), AddAssign(add_assign), rhs = (T, T) => rhs.0, rhs.1); +impl_point_op!(-, Sub(sub), SubAssign(sub_assign), rhs = (T, T) => rhs.0, rhs.1); +impl_point_op!(*, Mul(mul), MulAssign(mul_assign), rhs = (T, T) => rhs.0, rhs.1); +impl_point_op!(/, Div(div), DivAssign(div_assign), rhs = (T, T) => rhs.0, rhs.1); +impl_point_op!(*, Mul(mul), MulAssign(mul_assign), rhs = Dimension => rhs.width, rhs.height); +impl_point_op!(/, Div(div), DivAssign(div_assign), rhs = Dimension => rhs.width, rhs.height); ////////// multiply point with scalar ////////////////////////////////////////// impl + Copy> Mul for Point {