From 0adbbd478be28b92ae6bbb266b6f9ff8cc211ec8 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sat, 1 Dec 2012 15:05:11 +1000 Subject: [PATCH] Implement explicit self for DefaultEq trait --- src/mat.rs | 6 +++--- src/num/default_eq.rs | 30 +++++++++++++++--------------- src/quat.rs | 2 +- src/vec.rs | 6 +++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/mat.rs b/src/mat.rs index 06996e0..f708430 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -355,7 +355,7 @@ pub impl Mat2: FuzzyEq { pub impl Mat2: DefaultEq { #[inline(always)] - pure fn default_eq(other: &Mat2) -> bool { + pure fn default_eq(&self, other: &Mat2) -> bool { self[0].default_eq(&other[0]) && self[1].default_eq(&other[1]) } @@ -660,7 +660,7 @@ pub impl Mat3: FuzzyEq { pub impl Mat3: DefaultEq { #[inline(always)] - pure fn default_eq(other: &Mat3) -> bool { + pure fn default_eq(&self, other: &Mat3) -> bool { self[0].default_eq(&other[0]) && self[1].default_eq(&other[1]) && self[2].default_eq(&other[2]) @@ -1016,7 +1016,7 @@ pub impl Mat4: FuzzyEq { pub impl Mat4: DefaultEq { #[inline(always)] - pure fn default_eq(other: &Mat4) -> bool { + pure fn default_eq(&self, other: &Mat4) -> bool { self[0].default_eq(&other[0]) && self[1].default_eq(&other[1]) && self[2].default_eq(&other[2]) && diff --git a/src/num/default_eq.rs b/src/num/default_eq.rs index 4d1036f..0566a0c 100644 --- a/src/num/default_eq.rs +++ b/src/num/default_eq.rs @@ -2,23 +2,23 @@ use std::cmp::FuzzyEq; pub trait DefaultEq { - pure fn default_eq(other: &self) -> bool; + pure fn default_eq(&self, other: &self) -> bool; } -pub impl bool: DefaultEq { #[inline(always)] pure fn default_eq(other: &bool) -> bool { self == *other } } +pub impl bool: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &bool) -> bool { (*self) == (*other) } } -pub impl u8: DefaultEq { #[inline(always)] pure fn default_eq(other: &u8) -> bool { self == *other } } -pub impl u16: DefaultEq { #[inline(always)] pure fn default_eq(other: &u16) -> bool { self == *other } } -pub impl u32: DefaultEq { #[inline(always)] pure fn default_eq(other: &u32) -> bool { self == *other } } -pub impl u64: DefaultEq { #[inline(always)] pure fn default_eq(other: &u64) -> bool { self == *other } } -pub impl uint: DefaultEq { #[inline(always)] pure fn default_eq(other: &uint) -> bool { self == *other } } +pub impl u8: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &u8) -> bool { (*self) == (*other) } } +pub impl u16: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &u16) -> bool { (*self) == (*other) } } +pub impl u32: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &u32) -> bool { (*self) == (*other) } } +pub impl u64: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &u64) -> bool { (*self) == (*other) } } +pub impl uint: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &uint) -> bool { (*self) == (*other) } } -pub impl i8: DefaultEq { #[inline(always)] pure fn default_eq(other: &i8) -> bool { self == *other } } -pub impl i16: DefaultEq { #[inline(always)] pure fn default_eq(other: &i16) -> bool { self == *other } } -pub impl i32: DefaultEq { #[inline(always)] pure fn default_eq(other: &i32) -> bool { self == *other } } -pub impl i64: DefaultEq { #[inline(always)] pure fn default_eq(other: &i64) -> bool { self == *other } } -pub impl int: DefaultEq { #[inline(always)] pure fn default_eq(other: &int) -> bool { self == *other } } +pub impl i8: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &i8) -> bool { (*self) == (*other) } } +pub impl i16: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &i16) -> bool { (*self) == (*other) } } +pub impl i32: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &i32) -> bool { (*self) == (*other) } } +pub impl i64: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &i64) -> bool { (*self) == (*other) } } +pub impl int: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &int) -> bool { (*self) == (*other) } } -pub impl f32: DefaultEq { #[inline(always)] pure fn default_eq(other: &f32) -> bool { self.fuzzy_eq(other) } } -pub impl f64: DefaultEq { #[inline(always)] pure fn default_eq(other: &f64) -> bool { self.fuzzy_eq(other) } } -pub impl float: DefaultEq { #[inline(always)] pure fn default_eq(other: &float) -> bool { self.fuzzy_eq(other) } } \ No newline at end of file +pub impl f32: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &f32) -> bool { self.fuzzy_eq(other) } } +pub impl f64: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &f64) -> bool { self.fuzzy_eq(other) } } +pub impl float: DefaultEq { #[inline(always)] pure fn default_eq(&self, other: &float) -> bool { self.fuzzy_eq(other) } } \ No newline at end of file diff --git a/src/quat.rs b/src/quat.rs index dd8099e..560104b 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -295,7 +295,7 @@ pub impl Quat: FuzzyEq { pub impl Quat: DefaultEq { #[inline(always)] - pure fn default_eq(other: &Quat) -> bool { + pure fn default_eq(&self, other: &Quat) -> bool { self[0].default_eq(&other[0]) && self[1].default_eq(&other[1]) && self[2].default_eq(&other[2]) && diff --git a/src/vec.rs b/src/vec.rs index 5dbf0b3..25a9c3f 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -239,7 +239,7 @@ pub impl Vec2: FuzzyEq { pub impl Vec2: DefaultEq { #[inline(always)] - pure fn default_eq(other: &Vec2) -> bool { + pure fn default_eq(&self, other: &Vec2) -> bool { self[0].default_eq(&other[0]) && self[1].default_eq(&other[1]) } @@ -418,7 +418,7 @@ pub impl Vec3: FuzzyEq { pub impl Vec3: DefaultEq { #[inline(always)] - pure fn default_eq(other: &Vec3) -> bool { + pure fn default_eq(&self, other: &Vec3) -> bool { self[0].default_eq(&other[0]) && self[1].default_eq(&other[1]) && self[2].default_eq(&other[2]) @@ -597,7 +597,7 @@ pub impl Vec4: FuzzyEq { pub impl Vec4: DefaultEq { #[inline(always)] - pure fn default_eq(other: &Vec4) -> bool { + pure fn default_eq(&self, other: &Vec4) -> bool { self[0].default_eq(&other[0]) && self[1].default_eq(&other[1]) && self[2].default_eq(&other[2]) &&