Separate operator overload implementations

This commit is contained in:
Brendan Zabarauskas 2012-11-27 12:35:29 +10:00
parent d7d1c786fb
commit ca40caee81

View file

@ -36,11 +36,29 @@ pub impl<T:Copy Num NumCast> Radians<T>: Angle<T> {
#[inline(always)] pure fn to_radians() -> Radians<T> { self } #[inline(always)] pure fn to_radians() -> Radians<T> { self }
#[inline(always)] pure fn to_degrees() -> Degrees<T> { Degrees(*self * cast(180.0 / pi)) } #[inline(always)] pure fn to_degrees() -> Degrees<T> { Degrees(*self * cast(180.0 / pi)) }
}
pub impl<T:Copy Num> Radians<T>: Add<Radians<T>, Radians<T>> {
#[inline(always)] pure fn add(rhs: &Radians<T>) -> Radians<T> { Radians(*self + **rhs) } #[inline(always)] pure fn add(rhs: &Radians<T>) -> Radians<T> { Radians(*self + **rhs) }
}
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) } #[inline(always)] pure fn sub(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) } #[inline(always)] pure fn mul(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) } #[inline(always)] pure fn div(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) } #[inline(always)] pure fn modulo(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) } #[inline(always)] pure fn neg() -> Radians<T> { Radians(-*self) }
} }
@ -67,11 +85,29 @@ pub impl<T:Copy Num NumCast> Degrees<T>: Angle<T> {
#[inline(always)] pure fn to_radians() -> Radians<T> { Radians(*self * cast(pi / 180.0)) } #[inline(always)] pure fn to_radians() -> Radians<T> { Radians(*self * cast(pi / 180.0)) }
#[inline(always)] pure fn to_degrees() -> Degrees<T> { self } #[inline(always)] pure fn to_degrees() -> Degrees<T> { self }
}
pub impl<T:Copy Num> Degrees<T>: Add<Degrees<T>, Degrees<T>> {
#[inline(always)] pure fn add(rhs: &Degrees<T>) -> Degrees<T> { Degrees(*self + **rhs) } #[inline(always)] pure fn add(rhs: &Degrees<T>) -> Degrees<T> { Degrees(*self + **rhs) }
}
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) } #[inline(always)] pure fn sub(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(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(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(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() -> Degrees<T> { Degrees(-*self) }
} }