Skip to content

Commit 4606e32

Browse files
author
James O'Cull
committed
Absolute paths to the rescue! Macro fixed.
1 parent d34148f commit 4606e32

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/measurement.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@ pub trait Measurement {
66
#[macro_export]
77
macro_rules! implement_measurement {
88
($($t:ty)*) => ($(
9-
// TODO: Find a better way to reference these...
10-
use std::ops::{Add,Sub,Div,Mul};
11-
use std::cmp::{Eq, PartialEq};
12-
use std::cmp::{PartialOrd, Ordering};
13-
14-
impl Add for $t {
9+
impl ::std::ops::Add for $t {
1510
type Output = Self;
1611

1712
fn add(self, rhs: Self) -> Self {
1813
Self::from_base_units(self.get_base_units() + rhs.get_base_units())
1914
}
2015
}
2116

22-
impl Sub for $t {
17+
impl ::std::ops::Sub for $t {
2318
type Output = Self;
2419

2520
fn sub(self, rhs: Self) -> Self {
@@ -30,7 +25,7 @@ macro_rules! implement_measurement {
3025
///
3126
/// Dividing a `$t` by another `$` returns a ratio.
3227
///
33-
impl Div<$t> for $t {
28+
impl ::std::ops::Div<$t> for $t {
3429
type Output = f64;
3530

3631
fn div(self, rhs: Self) -> f64 {
@@ -41,7 +36,7 @@ macro_rules! implement_measurement {
4136
///
4237
/// Dividing a `$` by a factor returns a new portion of the measurement.
4338
///
44-
impl Div<f64> for $t {
39+
impl ::std::ops::Div<f64> for $t {
4540
type Output = Self;
4641

4742
fn div(self, rhs: f64) -> Self {
@@ -52,7 +47,7 @@ macro_rules! implement_measurement {
5247
///
5348
/// Multiplying a `$t` by another `$t` returns the product of those measurements.
5449
///
55-
impl Mul<$t> for $t {
50+
impl ::std::ops::Mul<$t> for $t {
5651
type Output = Self;
5752

5853
fn mul(self, rhs: Self) -> Self {
@@ -63,23 +58,23 @@ macro_rules! implement_measurement {
6358
///
6459
/// Multiplying a `$t` by a factor increases (or decreases) that measurement a number of times.
6560
///
66-
impl Mul<f64> for $t {
61+
impl ::std::ops::Mul<f64> for $t {
6762
type Output = Self;
6863

6964
fn mul(self, rhs: f64) -> Self {
7065
Self::from_base_units(self.get_base_units() * rhs)
7166
}
7267
}
7368

74-
impl Eq for $t { }
75-
impl PartialEq for $t {
69+
impl ::std::cmp::Eq for $t { }
70+
impl ::std::cmp::PartialEq for $t {
7671
fn eq(&self, other: &Self) -> bool {
7772
self.get_base_units() == other.get_base_units()
7873
}
7974
}
8075

81-
impl PartialOrd for $t {
82-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
76+
impl ::std::cmp::PartialOrd for $t {
77+
fn partial_cmp(&self, other: &Self) -> Option<::std::cmp::Ordering> {
8378
self.get_base_units().partial_cmp(&other.get_base_units())
8479
}
8580
}

0 commit comments

Comments
 (0)