Fix Neg trait taking self instead of &self

This commit is contained in:
Pierre Krieger 2014-12-23 19:09:06 +01:00
parent 7bfad8e118
commit 258e7465d4
7 changed files with 13 additions and 13 deletions

View File

@ -576,7 +576,7 @@ pub fn inv_rotate<V, M: Rotate<V>>(m: &M, v: &V) -> V {
/// Rotates a copy of `m` by `amount` using `center` as the pivot point. /// Rotates a copy of `m` by `amount` using `center` as the pivot point.
#[inline(always)] #[inline(always)]
pub fn append_rotation_wrt_point<LV: Neg<LV>, pub fn append_rotation_wrt_point<LV: Neg<LV> + Copy,
AV, AV,
M: RotationWithTranslation<LV, AV>>( M: RotationWithTranslation<LV, AV>>(
m: &M, m: &M,
@ -587,7 +587,7 @@ pub fn append_rotation_wrt_point<LV: Neg<LV>,
/// Rotates a copy of `m` by `amount` using `m.translation()` as the pivot point. /// Rotates a copy of `m` by `amount` using `m.translation()` as the pivot point.
#[inline(always)] #[inline(always)]
pub fn append_rotation_wrt_center<LV: Neg<LV>, pub fn append_rotation_wrt_center<LV: Neg<LV> + Copy,
AV, AV,
M: RotationWithTranslation<LV, AV>>( M: RotationWithTranslation<LV, AV>>(
m: &M, m: &M,

View File

@ -250,9 +250,9 @@ macro_rules! dvec_impl(
} }
} }
impl<N: Neg<N> + Zero> Neg<$dvec<N>> for $dvec<N> { impl<N: Neg<N> + Zero + Copy> Neg<$dvec<N>> for $dvec<N> {
#[inline] #[inline]
fn neg(&self) -> $dvec<N> { fn neg(self) -> $dvec<N> {
FromIterator::from_iter(self.as_slice().iter().map(|a| -*a)) FromIterator::from_iter(self.as_slice().iter().map(|a| -*a))
} }
} }

View File

@ -54,7 +54,7 @@ impl<N> Quat<N> {
} }
} }
impl<N: Neg<N>> Quat<N> { impl<N: Neg<N> + Copy> Quat<N> {
/// Replaces this quaternion by its conjugate. /// Replaces this quaternion by its conjugate.
#[inline] #[inline]
pub fn conjugate(&mut self) { pub fn conjugate(&mut self) {

View File

@ -18,7 +18,7 @@ pub struct Rot2<N> {
submat: Mat2<N> submat: Mat2<N>
} }
impl<N: Clone + BaseFloat + Neg<N>> Rot2<N> { impl<N: Clone + BaseFloat + Neg<N> + Copy> Rot2<N> {
/// Builds a 2 dimensional rotation matrix from an angle in radian. /// Builds a 2 dimensional rotation matrix from an angle in radian.
pub fn new(angle: Vec1<N>) -> Rot2<N> { pub fn new(angle: Vec1<N>) -> Rot2<N> {
let (sia, coa) = angle.x.sin_cos(); let (sia, coa) = angle.x.sin_cos();
@ -66,7 +66,7 @@ impl<N: BaseFloat + Clone> Rotation<Vec1<N>> for Rot2<N> {
} }
} }
impl<N: Clone + Rand + BaseFloat + Neg<N>> Rand for Rot2<N> { impl<N: Clone + Rand + BaseFloat + Neg<N> + Copy> Rand for Rot2<N> {
#[inline] #[inline]
fn rand<R: Rng>(rng: &mut R) -> Rot2<N> { fn rand<R: Rng>(rng: &mut R) -> Rot2<N> {
Rot2::new(rng.gen()) Rot2::new(rng.gen())

View File

@ -112,9 +112,9 @@ impl<N, T> Sub<T, vec::Vec0<N>> for vec::Vec0<N> {
} }
} }
impl<N: Neg<N>> Neg<vec::Vec0<N>> for vec::Vec0<N> { impl<N: Neg<N> + Copy> Neg<vec::Vec0<N>> for vec::Vec0<N> {
#[inline] #[inline]
fn neg(&self) -> vec::Vec0<N> { fn neg(self) -> vec::Vec0<N> {
vec::Vec0 vec::Vec0
} }
} }

View File

@ -480,9 +480,9 @@ macro_rules! scalar_div_impl(
macro_rules! neg_impl( macro_rules! neg_impl(
($t: ident, $comp0: ident $(,$compN: ident)*) => ( ($t: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Neg<N>> Neg<$t<N>> for $t<N> { impl<N: Neg<N> + Copy> Neg<$t<N>> for $t<N> {
#[inline] #[inline]
fn neg(&self) -> $t<N> { fn neg(self) -> $t<N> {
$t::new(-self.$comp0 $(, -self.$compN )*) $t::new(-self.$comp0 $(, -self.$compN )*)
} }
} }

View File

@ -82,7 +82,7 @@ pub trait Rotate<V> {
/// ///
/// Those operations are automatically implemented in term of the `Rotation` and `Translation` /// Those operations are automatically implemented in term of the `Rotation` and `Translation`
/// traits. /// traits.
pub trait RotationWithTranslation<LV: Neg<LV>, AV>: Rotation<AV> + Translation<LV> { pub trait RotationWithTranslation<LV: Neg<LV> + Copy, AV>: Rotation<AV> + Translation<LV> {
/// Applies a rotation centered on a specific point. /// Applies a rotation centered on a specific point.
/// ///
/// # Arguments /// # Arguments
@ -136,7 +136,7 @@ pub trait RotationWithTranslation<LV: Neg<LV>, AV>: Rotation<AV> + Translation<L
} }
} }
impl<LV: Neg<LV>, AV, M: Rotation<AV> + Translation<LV>> RotationWithTranslation<LV, AV> for M { impl<LV: Neg<LV> + Copy, AV, M: Rotation<AV> + Translation<LV>> RotationWithTranslation<LV, AV> for M {
} }
/// Trait of transformation having a rotation extractable as a rotation matrix. This can typically /// Trait of transformation having a rotation extractable as a rotation matrix. This can typically