From e1a74749d0a620da507e2845f497ccec25a66221 Mon Sep 17 00:00:00 2001 From: "Kevin R. Thornton" Date: Wed, 8 May 2024 15:43:46 -0700 Subject: [PATCH] fix awkward macro implementaiton --- src/sys/macros.rs | 4 ++-- src/sys/newtypes.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sys/macros.rs b/src/sys/macros.rs index 6c04b390..8d81e1fb 100644 --- a/src/sys/macros.rs +++ b/src/sys/macros.rs @@ -175,7 +175,7 @@ macro_rules! impl_f64_newtypes { // NOTE: this macro def'n is awkward // because we sometimes need a token as // a type and other times as an expression - ($type: ty, $type_as_expr: expr) => { + ($type: ident) => { impl std::fmt::Display for $type { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.0) @@ -280,7 +280,7 @@ macro_rules! impl_f64_newtypes { type Output = $type; fn add(self, rhs: Self) -> Self::Output { - $type_as_expr(self.0 + rhs.0) + $type(self.0 + rhs.0) } } diff --git a/src/sys/newtypes.rs b/src/sys/newtypes.rs index 4a93b506..02894300 100644 --- a/src/sys/newtypes.rs +++ b/src/sys/newtypes.rs @@ -179,9 +179,9 @@ pub struct Position(f64); #[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] pub struct Location(f64); -impl_f64_newtypes!(Time, Time); -impl_f64_newtypes!(Position, Position); -impl_f64_newtypes!(Location, Location); +impl_f64_newtypes!(Time); +impl_f64_newtypes!(Position); +impl_f64_newtypes!(Location); // It is natural to be able to * and / times and positions impl_time_position_arithmetic!(Time, Position);