Skip to content

Commit

Permalink
fix awkward macro implementaiton
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed May 8, 2024
1 parent 36fb522 commit e1a7474
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/sys/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/sys/newtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e1a7474

Please sign in to comment.