Use #[deriving_eq] instead of Eq

This commit is contained in:
Brendan Zabarauskas 2012-12-20 15:18:23 +10:00
parent 25dddc1655
commit 65e301d52d
7 changed files with 7 additions and 99 deletions

View file

@ -24,6 +24,7 @@ use vec::Vec2;
* * `y` - the second column vector of the matrix
* * `z` - the third column vector of the matrix
*/
#[deriving_eq]
pub struct Mat2<T> { x: Vec2<T>, y: Vec2<T> }
pub impl<T:Copy Float> Mat2<T> {
@ -380,19 +381,6 @@ pub impl<T:Copy Float> Mat2<T>: Neg<Mat2<T>> {
}
}
pub impl<T:Copy Float> Mat2<T>: Eq {
#[inline(always)]
pure fn eq(&self, other: &Mat2<T>) -> bool {
self[0] == other[0] &&
self[1] == other[1]
}
#[inline(always)]
pure fn ne(&self, other: &Mat2<T>) -> bool {
!(self == other)
}
}
pub impl<T:Copy Float> Mat2<T>: FuzzyEq {
#[inline(always)]
pure fn fuzzy_eq(other: &Mat2<T>) -> bool {

View file

@ -25,6 +25,7 @@ use vec::Vec3;
* * `y` - the second column vector of the matrix
* * `z` - the third column vector of the matrix
*/
#[deriving_eq]
pub struct Mat3<T> { x: Vec3<T>, y: Vec3<T>, z: Vec3<T> }
pub impl<T:Copy Float> Mat3<T> {
@ -575,20 +576,6 @@ pub impl<T:Copy Float> Mat3<T>: Neg<Mat3<T>> {
}
}
pub impl<T:Copy Float> Mat3<T>: Eq {
#[inline(always)]
pure fn eq(&self, other: &Mat3<T>) -> bool {
self[0] == other[0] &&
self[1] == other[1] &&
self[2] == other[2]
}
#[inline(always)]
pure fn ne(&self, other: &Mat3<T>) -> bool {
!(self == other)
}
}
pub impl<T:Copy Float> Mat3<T>: FuzzyEq {
#[inline(always)]
pure fn fuzzy_eq(other: &Mat3<T>) -> bool {

View file

@ -25,6 +25,7 @@ use vec::Vec4;
* * `z` - the third column vector of the matrix
* * `w` - the fourth column vector of the matrix
*/
#[deriving_eq]
pub struct Mat4<T> { x: Vec4<T>, y: Vec4<T>, z: Vec4<T>, w: Vec4<T> }
pub impl<T:Copy Float> Mat4<T> {
@ -520,21 +521,6 @@ pub impl<T:Copy> Mat4<T>: Index<uint, Vec4<T>> {
}
}
pub impl<T:Copy Float> Mat4<T>: Eq {
#[inline(always)]
pure fn eq(&self, other: &Mat4<T>) -> bool {
self[0] == other[0] &&
self[1] == other[1] &&
self[2] == other[2] &&
self[3] == other[3]
}
#[inline(always)]
pure fn ne(&self, other: &Mat4<T>) -> bool {
!(self == other)
}
}
pub impl<T:Copy Float> Mat4<T>: FuzzyEq {
#[inline(always)]
pure fn fuzzy_eq(other: &Mat4<T>) -> bool {

View file

@ -198,6 +198,7 @@ pub trait Quaternion<T,V3>: Index<uint, T> Eq Neg<self> {
* * `s` - the scalar component
* * `v` - a vector containing the three imaginary components
*/
#[deriving_eq]
pub struct Quat<T> { s: T, v: Vec3<T> }
pub impl<T:Copy Float> Quat<T> {
@ -460,21 +461,6 @@ pub impl<T:Copy Float> Quat<T>: Neg<Quat<T>> {
}
}
pub impl<T:Copy Eq> Quat<T>: Eq {
#[inline(always)]
pure fn eq(&self, other: &Quat<T>) -> bool {
self[0] == other[0] &&
self[1] == other[1] &&
self[2] == other[2] &&
self[3] == other[3]
}
#[inline(always)]
pure fn ne(&self, other: &Quat<T>) -> bool {
!(self == other)
}
}
pub impl<T:Copy FuzzyEq> Quat<T>: FuzzyEq {
#[inline(always)]
pure fn fuzzy_eq(other: &Quat<T>) -> bool {

View file

@ -22,6 +22,7 @@ use numeric::types::number::Number;
* * `x` - the first component of the vector
* * `y` - the second component of the vector
*/
#[deriving_eq]
pub struct Vec2<T> { x: T, y: T }
pub impl<T> Vec2<T>/*: Vector2<T>*/ {
@ -225,19 +226,6 @@ pub impl<T:Copy Float> Vec2<T>: MutableEuclideanVector<&self/T> {
}
}
pub impl<T:Copy Eq> Vec2<T>: Eq {
#[inline(always)]
pure fn eq(&self, other: &Vec2<T>) -> bool {
self[0] == other[0] &&
self[1] == other[1]
}
#[inline(always)]
pure fn ne(&self, other: &Vec2<T>) -> bool {
!(self == other)
}
}
pub impl<T:Copy FuzzyEq> Vec2<T>: FuzzyEq {
#[inline(always)]
pure fn fuzzy_eq(other: &Vec2<T>) -> bool {

View file

@ -23,6 +23,7 @@ use numeric::types::number::Number;
* * `y` - the second component of the vector
* * `z` - the third component of the vector
*/
#[deriving_eq]
pub struct Vec3<T> { x: T, y: T, z: T }
pub impl<T> Vec3<T>/*: Vector3<T>*/ {
@ -248,20 +249,6 @@ pub impl<T:Copy Float> Vec3<T>: MutableEuclideanVector<&self/T> {
}
}
pub impl<T:Copy Eq> Vec3<T>: Eq {
#[inline(always)]
pure fn eq(&self, other: &Vec3<T>) -> bool {
self[0] == other[0] &&
self[1] == other[1] &&
self[2] == other[2]
}
#[inline(always)]
pure fn ne(&self, other: &Vec3<T>) -> bool {
!(self == other)
}
}
pub impl<T:Copy FuzzyEq> Vec3<T>: FuzzyEq {
#[inline(always)]
pure fn fuzzy_eq(other: &Vec3<T>) -> bool {

View file

@ -24,6 +24,7 @@ use numeric::types::number::Number;
* * `z` - the third component of the vector
* * `w` - the fourth component of the vector
*/
#[deriving_eq]
pub struct Vec4<T> { x: T, y: T, z: T, w: T }
pub impl<T> Vec4<T>/*: Vector4<T>*/ {
@ -246,21 +247,6 @@ pub impl<T:Copy Float> Vec4<T>: MutableEuclideanVector<&self/T> {
}
}
pub impl<T:Copy Eq> Vec4<T>: Eq {
#[inline(always)]
pure fn eq(&self, other: &Vec4<T>) -> bool {
self[0] == other[0] &&
self[1] == other[1] &&
self[2] == other[2] &&
self[3] == other[3]
}
#[inline(always)]
pure fn ne(&self, other: &Vec4<T>) -> bool {
!(self == other)
}
}
pub impl<T:Copy FuzzyEq> Vec4<T>: FuzzyEq {
#[inline(always)]
pure fn fuzzy_eq(other: &Vec4<T>) -> bool {