Merge pull request #151 from serpis/fix_neg_trait

Update to match latest Neg trait.
This commit is contained in:
Colin Sherratt 2014-12-21 12:36:31 -05:00
commit 98ab67ee7c
4 changed files with 8 additions and 8 deletions

View file

@ -89,7 +89,7 @@ pub trait Angle
fn from<A: Angle<S>>(theta: A) -> Self;
/// Negate this angle, in-place.
#[inline] fn neg_self(&mut self) { *self = -*self }
#[inline] fn neg_self(&mut self) { *self = -(*self).clone() }
/// Add this angle with another, returning the new angle.
#[inline] fn add_a(&self, other: Self) -> Self { ScalarConv::from(*self.s() + *other.s()) }
@ -186,8 +186,8 @@ impl<S: BaseFloat> Add<Deg<S>, Deg<S>> for Deg<S> { #[inline] fn add(self, other
impl<S: BaseFloat> Sub<Rad<S>, Rad<S>> for Rad<S> { #[inline] fn sub(self, other: Rad<S>) -> Rad<S> { rad(self.s - other.s) } }
impl<S: BaseFloat> Sub<Deg<S>, Deg<S>> for Deg<S> { #[inline] fn sub(self, other: Deg<S>) -> Deg<S> { deg(self.s - other.s) } }
impl<S: BaseFloat> Neg<Rad<S>> for Rad<S> { #[inline] fn neg(&self) -> Rad<S> { rad(-self.s) } }
impl<S: BaseFloat> Neg<Deg<S>> for Deg<S> { #[inline] fn neg(&self) -> Deg<S> { deg(-self.s) } }
impl<S: BaseFloat> Neg<Rad<S>> for Rad<S> { #[inline] fn neg(self) -> Rad<S> { rad(-self.s) } }
impl<S: BaseFloat> Neg<Deg<S>> for Deg<S> { #[inline] fn neg(self) -> Deg<S> { deg(-self.s) } }
impl<S: BaseFloat> Zero for Rad<S> { #[inline] fn zero() -> Rad<S> { rad(zero()) } #[inline] fn is_zero(&self) -> bool { *self == zero() } }
impl<S: BaseFloat> Zero for Deg<S> { #[inline] fn zero() -> Deg<S> { deg(zero()) } #[inline] fn is_zero(&self) -> bool { *self == zero() } }

View file

@ -377,9 +377,9 @@ impl<S: BaseFloat + 'static> Sub<Matrix2<S>, Matrix2<S>> for Matrix2<S> { #[inli
impl<S: BaseFloat + 'static> Sub<Matrix3<S>, Matrix3<S>> for Matrix3<S> { #[inline] fn sub(self, other: Matrix3<S>) -> Matrix3<S> { self.sub_m(&other) } }
impl<S: BaseFloat + 'static> Sub<Matrix4<S>, Matrix4<S>> for Matrix4<S> { #[inline] fn sub(self, other: Matrix4<S>) -> Matrix4<S> { self.sub_m(&other) } }
impl<S: BaseFloat> Neg<Matrix2<S>> for Matrix2<S> { #[inline] fn neg(&self) -> Matrix2<S> { Matrix2::from_cols(self[0].neg(), self[1].neg()) } }
impl<S: BaseFloat> Neg<Matrix3<S>> for Matrix3<S> { #[inline] fn neg(&self) -> Matrix3<S> { Matrix3::from_cols(self[0].neg(), self[1].neg(), self[2].neg()) } }
impl<S: BaseFloat> Neg<Matrix4<S>> for Matrix4<S> { #[inline] fn neg(&self) -> Matrix4<S> { Matrix4::from_cols(self[0].neg(), self[1].neg(), self[2].neg(), self[3].neg()) } }
impl<S: BaseFloat> Neg<Matrix2<S>> for Matrix2<S> { #[inline] fn neg(self) -> Matrix2<S> { Matrix2::from_cols(self[0].neg(), self[1].neg()) } }
impl<S: BaseFloat> Neg<Matrix3<S>> for Matrix3<S> { #[inline] fn neg(self) -> Matrix3<S> { Matrix3::from_cols(self[0].neg(), self[1].neg(), self[2].neg()) } }
impl<S: BaseFloat> Neg<Matrix4<S>> for Matrix4<S> { #[inline] fn neg(self) -> Matrix4<S> { Matrix4::from_cols(self[0].neg(), self[1].neg(), self[2].neg(), self[3].neg()) } }
impl<S: BaseFloat> Zero for Matrix2<S> { #[inline] fn zero() -> Matrix2<S> { Matrix2::zero() } #[inline] fn is_zero(&self) -> bool{ *self == zero() } }
impl<S: BaseFloat> Zero for Matrix3<S> { #[inline] fn zero() -> Matrix3<S> { Matrix3::zero() } #[inline] fn is_zero(&self) -> bool{ *self == zero() } }

View file

@ -358,7 +358,7 @@ impl<S: BaseFloat> ToMatrix4<S> for Quaternion<S> {
impl<S: BaseFloat> Neg<Quaternion<S>> for Quaternion<S> {
#[inline]
fn neg(&self) -> Quaternion<S> {
fn neg(self) -> Quaternion<S> {
Quaternion::from_sv(-self.s, -self.v)
}
}

View file

@ -313,7 +313,7 @@ macro_rules! vec(
}
impl<S: BaseNum> Neg<$Self<S>> for $Self<S> {
#[inline] fn neg(&self) -> $Self<S> { $Self::new($(-self.$field),+) }
#[inline] fn neg(self) -> $Self<S> { $Self::new($(-self.$field),+) }
}
impl<S: BaseNum> Mul<$Self<S>, $Self<S>> for $Self<S> {