Workaround conflicting loans when using util::swap.

This commit is contained in:
Luqman Aden 2013-03-28 18:24:35 -07:00
parent a467bf7032
commit 062a5126e4
8 changed files with 26 additions and 32 deletions

View file

@ -28,4 +28,4 @@ mod test {
#[path = "test_mat.rs" ] mod mat; #[path = "test_mat.rs" ] mod mat;
#[path = "test_quat.rs"] mod quat; #[path = "test_quat.rs"] mod quat;
#[path = "test_vec.rs" ] mod vec; #[path = "test_vec.rs" ] mod vec;
} }

View file

@ -300,4 +300,4 @@ pub trait MutableMatrix<T,V>: Matrix<T,V> {
* Sets the matrix to its transpose * Sets the matrix to its transpose
*/ */
fn transpose_self(&mut self); fn transpose_self(&mut self);
} }

View file

@ -220,8 +220,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
swap(self.col_mut(a), *self.col_mut(a) <-> *self.col_mut(b);
self.col_mut(b));
} }
#[inline(always)] #[inline(always)]

View file

@ -488,8 +488,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
swap(self.col_mut(a), *self.col_mut(a) <-> *self.col_mut(b);
self.col_mut(b));
} }
#[inline(always)] #[inline(always)]
@ -545,14 +544,14 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn transpose_self(&mut self) { fn transpose_self(&mut self) {
swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); *self.col_mut(0).index_mut(1) <-> *self.col_mut(1).index_mut(0);
swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0)); *self.col_mut(0).index_mut(2) <-> *self.col_mut(2).index_mut(0);
swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); *self.col_mut(1).index_mut(0) <-> *self.col_mut(0).index_mut(1);
swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1)); *self.col_mut(1).index_mut(2) <-> *self.col_mut(2).index_mut(1);
swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2)); *self.col_mut(2).index_mut(0) <-> *self.col_mut(0).index_mut(2);
swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); *self.col_mut(2).index_mut(1) <-> *self.col_mut(1).index_mut(2);
} }
} }

View file

@ -413,8 +413,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
swap(self.col_mut(a), *self.col_mut(a) <-> *self.col_mut(b);
self.col_mut(b));
} }
#[inline(always)] #[inline(always)]
@ -474,21 +473,21 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn transpose_self(&mut self) { fn transpose_self(&mut self) {
swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); *self.col_mut(0).index_mut(1) <-> *self.col_mut(1).index_mut(0);
swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0)); *self.col_mut(0).index_mut(2) <-> *self.col_mut(2).index_mut(0);
swap(self.col_mut(0).index_mut(3), self.col_mut(3).index_mut(0)); *self.col_mut(0).index_mut(3) <-> *self.col_mut(3).index_mut(0);
swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); *self.col_mut(1).index_mut(0) <-> *self.col_mut(0).index_mut(1);
swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1)); *self.col_mut(1).index_mut(2) <-> *self.col_mut(2).index_mut(1);
swap(self.col_mut(1).index_mut(3), self.col_mut(3).index_mut(1)); *self.col_mut(1).index_mut(3) <-> *self.col_mut(3).index_mut(1);
swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2)); *self.col_mut(2).index_mut(0) <-> *self.col_mut(0).index_mut(2);
swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); *self.col_mut(2).index_mut(1) <-> *self.col_mut(1).index_mut(2);
swap(self.col_mut(2).index_mut(3), self.col_mut(3).index_mut(2)); *self.col_mut(2).index_mut(3) <-> *self.col_mut(3).index_mut(2);
swap(self.col_mut(3).index_mut(0), self.col_mut(0).index_mut(3)); *self.col_mut(3).index_mut(0) <-> *self.col_mut(0).index_mut(3);
swap(self.col_mut(3).index_mut(1), self.col_mut(1).index_mut(3)); *self.col_mut(3).index_mut(1) <-> *self.col_mut(1).index_mut(3);
swap(self.col_mut(3).index_mut(2), self.col_mut(2).index_mut(3)); *self.col_mut(3).index_mut(2) <-> *self.col_mut(2).index_mut(3);
} }
} }

View file

@ -85,8 +85,7 @@ impl<T:Copy> MutableVector<T> for Vec2<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
swap(self.index_mut(a), *self.index_mut(a) <-> *self.index_mut(b);
self.index_mut(b));
} }
} }

View file

@ -88,8 +88,7 @@ impl<T:Copy> MutableVector<T> for Vec3<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
swap(self.index_mut(a), *self.index_mut(a) <-> *self.index_mut(b);
self.index_mut(b));
} }
} }

View file

@ -87,8 +87,7 @@ impl<T:Copy> MutableVector<T> for Vec4<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
swap(self.index_mut(a), *self.index_mut(a) <-> *self.index_mut(b);
self.index_mut(b));
} }
} }