Update operator overloads to use explicit self
This commit is contained in:
parent
64761478dd
commit
49d055a3dc
4 changed files with 57 additions and 53 deletions
68
src/angle.rs
68
src/angle.rs
|
@ -55,49 +55,49 @@ pub impl<T:Copy Num> Radians<T>: Add<Radians<T>, Radians<T>> {
|
|||
|
||||
pub impl<T:Copy Num> Radians<T>: Sub<Radians<T>, Radians<T>> {
|
||||
#[inline(always)]
|
||||
pure fn sub(rhs: &Radians<T>) -> Radians<T> {
|
||||
Radians(*self - **rhs)
|
||||
pure fn sub(&self, rhs: &Radians<T>) -> Radians<T> {
|
||||
Radians(**self - **rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Radians<T>: Mul<T, Radians<T>> {
|
||||
#[inline(always)]
|
||||
pure fn mul(rhs: &T) -> Radians<T> {
|
||||
Radians(*self * *rhs)
|
||||
pure fn mul(&self, rhs: &T) -> Radians<T> {
|
||||
Radians(**self * *rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Radians<T>: Div<T, Radians<T>> {
|
||||
#[inline(always)]
|
||||
pure fn div(rhs: &T) -> Radians<T> {
|
||||
Radians(*self / *rhs)
|
||||
pure fn div(&self, rhs: &T) -> Radians<T> {
|
||||
Radians(**self / *rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Radians<T>: Modulo<T, Radians<T>> {
|
||||
#[inline(always)]
|
||||
pure fn modulo(rhs: &T) -> Radians<T> {
|
||||
Radians(*self % *rhs)
|
||||
pure fn modulo(&self, rhs: &T) -> Radians<T> {
|
||||
Radians(**self % *rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Radians<T>: Neg<Radians<T>> {
|
||||
#[inline(always)]
|
||||
pure fn neg() -> Radians<T> {
|
||||
Radians(-*self)
|
||||
pure fn neg(&self) -> Radians<T> {
|
||||
Radians(-**self)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Eq> Radians<T>: Eq {
|
||||
#[inline(always)] pure fn eq(other: &Radians<T>) -> bool { *self == **other }
|
||||
#[inline(always)] pure fn ne(other: &Radians<T>) -> bool { *self != **other }
|
||||
#[inline(always)] pure fn eq(&self, other: &Radians<T>) -> bool { **self == **other }
|
||||
#[inline(always)] pure fn ne(&self, other: &Radians<T>) -> bool { **self != **other }
|
||||
}
|
||||
|
||||
pub impl<T:Copy Ord> Radians<T>: Ord {
|
||||
#[inline(always)] pure fn lt(other: &Radians<T>) -> bool { *self < **other }
|
||||
#[inline(always)] pure fn le(other: &Radians<T>) -> bool { *self <= **other }
|
||||
#[inline(always)] pure fn ge(other: &Radians<T>) -> bool { *self >= **other }
|
||||
#[inline(always)] pure fn gt(other: &Radians<T>) -> bool { *self > **other }
|
||||
#[inline(always)] pure fn lt(&self, other: &Radians<T>) -> bool { **self < **other }
|
||||
#[inline(always)] pure fn le(&self, other: &Radians<T>) -> bool { **self <= **other }
|
||||
#[inline(always)] pure fn ge(&self, other: &Radians<T>) -> bool { **self >= **other }
|
||||
#[inline(always)] pure fn gt(&self, other: &Radians<T>) -> bool { **self > **other }
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,45 +129,49 @@ pub impl<T:Copy Num> Degrees<T>: Add<Degrees<T>, Degrees<T>> {
|
|||
|
||||
pub impl<T:Copy Num> Degrees<T>: Sub<Degrees<T>, Degrees<T>> {
|
||||
#[inline(always)]
|
||||
pure fn sub(rhs: &Degrees<T>) -> Degrees<T> {
|
||||
Degrees(*self - **rhs)
|
||||
pure fn sub(&self, rhs: &Degrees<T>) -> Degrees<T> {
|
||||
Degrees(**self - **rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Degrees<T>: Mul<T, Degrees<T>> {
|
||||
#[inline(always)] pure fn mul(rhs: &T) -> Degrees<T> {
|
||||
Degrees(*self * *rhs)
|
||||
#[inline(always)]
|
||||
pure fn mul(&self, rhs: &T) -> Degrees<T> {
|
||||
Degrees(**self * *rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Degrees<T>: Div<T, Degrees<T>> {
|
||||
#[inline(always)] pure fn div(rhs: &T) -> Degrees<T> {
|
||||
Degrees(*self / *rhs)
|
||||
#[inline(always)]
|
||||
pure fn div(&self, rhs: &T) -> Degrees<T> {
|
||||
Degrees(**self / *rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Degrees<T>: Modulo<T, Degrees<T>> {
|
||||
#[inline(always)] pure fn modulo(rhs: &T) -> Degrees<T> {
|
||||
Degrees(*self % *rhs)
|
||||
#[inline(always)]
|
||||
pure fn modulo(&self, rhs: &T) -> Degrees<T> {
|
||||
Degrees(**self % *rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Num> Degrees<T>: Neg<Degrees<T>> {
|
||||
#[inline(always)] pure fn neg() -> Degrees<T> {
|
||||
Degrees(-*self)
|
||||
#[inline(always)]
|
||||
pure fn neg(&self) -> Degrees<T> {
|
||||
Degrees(-**self)
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Copy Eq> Degrees<T>: Eq {
|
||||
#[inline(always)] pure fn eq(other: &Degrees<T>) -> bool { *self == **other }
|
||||
#[inline(always)] pure fn ne(other: &Degrees<T>) -> bool { *self != **other }
|
||||
#[inline(always)] pure fn eq(&self, other: &Degrees<T>) -> bool { **self == **other }
|
||||
#[inline(always)] pure fn ne(&self, other: &Degrees<T>) -> bool { **self != **other }
|
||||
}
|
||||
|
||||
pub impl<T:Copy Ord> Degrees<T>: Ord {
|
||||
#[inline(always)] pure fn lt(other: &Degrees<T>) -> bool { *self < **other }
|
||||
#[inline(always)] pure fn le(other: &Degrees<T>) -> bool { *self <= **other }
|
||||
#[inline(always)] pure fn ge(other: &Degrees<T>) -> bool { *self >= **other }
|
||||
#[inline(always)] pure fn gt(other: &Degrees<T>) -> bool { *self > **other }
|
||||
#[inline(always)] pure fn lt(&self, other: &Degrees<T>) -> bool { **self < **other }
|
||||
#[inline(always)] pure fn le(&self, other: &Degrees<T>) -> bool { **self <= **other }
|
||||
#[inline(always)] pure fn ge(&self, other: &Degrees<T>) -> bool { **self >= **other }
|
||||
#[inline(always)] pure fn gt(&self, other: &Degrees<T>) -> bool { **self > **other }
|
||||
}
|
||||
|
||||
|
||||
|
|
18
src/mat.rs
18
src/mat.rs
|
@ -326,13 +326,13 @@ pub impl<T:Copy NumCast> Mat2<T>: NumericMatrix2x2<T, Vec2<T>> {
|
|||
|
||||
pub impl<T:Copy DefaultEq> Mat2<T>: Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(other: &Mat2<T>) -> bool {
|
||||
pure fn eq(&self, other: &Mat2<T>) -> bool {
|
||||
self.default_eq(other)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn ne(other: &Mat2<T>) -> bool {
|
||||
!(self == *other)
|
||||
pure fn ne(&self, other: &Mat2<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,13 +620,13 @@ pub impl<T:Copy Num NumCast Ord DefaultEq> Mat3<T>: ToQuat<T> {
|
|||
|
||||
pub impl<T:Copy DefaultEq> Mat3<T>: Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(other: &Mat3<T>) -> bool {
|
||||
pure fn eq(&self, other: &Mat3<T>) -> bool {
|
||||
self.default_eq(other)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn ne(other: &Mat3<T>) -> bool {
|
||||
!(self == *other)
|
||||
pure fn ne(&self, other: &Mat3<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -964,13 +964,13 @@ pub impl<T> Mat4<T>: NumericMatrix4x4<T, Vec4<T>> {
|
|||
|
||||
pub impl<T:Copy DefaultEq> Mat4<T>: Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(other: &Mat4<T>) -> bool {
|
||||
pure fn eq(&self, other: &Mat4<T>) -> bool {
|
||||
self.default_eq(other)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn ne(other: &Mat4<T>) -> bool {
|
||||
!(self == *other)
|
||||
pure fn ne(&self, other: &Mat4<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -264,13 +264,13 @@ pub impl<T:Copy> Quat<T>: Index<uint, T> {
|
|||
|
||||
pub impl<T:Copy DefaultEq> Quat<T>: Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(other: &Quat<T>) -> bool {
|
||||
pure fn eq(&self, other: &Quat<T>) -> bool {
|
||||
self.default_eq(other)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn ne(other: &Quat<T>) -> bool {
|
||||
!(self == *other)
|
||||
pure fn ne(&self, other: &Quat<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
18
src/vec.rs
18
src/vec.rs
|
@ -211,13 +211,13 @@ pub impl<T:Copy Num NumCast Exp> Vec2<T>: GeometricVector<T> {
|
|||
|
||||
pub impl<T:Copy DefaultEq> Vec2<T>: Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(other: &Vec2<T>) -> bool {
|
||||
pure fn eq(&self, other: &Vec2<T>) -> bool {
|
||||
self.default_eq(other)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn ne(other: &Vec2<T>) -> bool {
|
||||
!(self == *other)
|
||||
pure fn ne(&self, other: &Vec2<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,13 +381,13 @@ pub impl<T:Copy Num NumCast Exp> Vec3<T>: GeometricVector<T> {
|
|||
|
||||
pub impl<T:Copy DefaultEq> Vec3<T>: Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(other: &Vec3<T>) -> bool {
|
||||
pure fn eq(&self, other: &Vec3<T>) -> bool {
|
||||
self.default_eq(other)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn ne(other: &Vec3<T>) -> bool {
|
||||
!(self == *other)
|
||||
pure fn ne(&self, other: &Vec3<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,13 +551,13 @@ pub impl<T:Copy Num NumCast Exp> Vec4<T>: GeometricVector<T> {
|
|||
|
||||
pub impl<T:Copy DefaultEq> Vec4<T>: Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(other: &Vec4<T>) -> bool {
|
||||
pure fn eq(&self, other: &Vec4<T>) -> bool {
|
||||
self.default_eq(other)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn ne(other: &Vec4<T>) -> bool {
|
||||
!(self == *other)
|
||||
pure fn ne(&self, other: &Vec4<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue