Workaround conflicting loans when using util::swap.
This commit is contained in:
parent
a467bf7032
commit
062a5126e4
8 changed files with 26 additions and 32 deletions
|
@ -28,4 +28,4 @@ mod test {
|
|||
#[path = "test_mat.rs" ] mod mat;
|
||||
#[path = "test_quat.rs"] mod quat;
|
||||
#[path = "test_vec.rs" ] mod vec;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,4 +300,4 @@ pub trait MutableMatrix<T,V>: Matrix<T,V> {
|
|||
* Sets the matrix to its transpose
|
||||
*/
|
||||
fn transpose_self(&mut self);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
fn swap_cols(&mut self, a: uint, b: uint) {
|
||||
swap(self.col_mut(a),
|
||||
self.col_mut(b));
|
||||
*self.col_mut(a) <-> *self.col_mut(b);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
15
src/mat3.rs
15
src/mat3.rs
|
@ -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)]
|
||||
fn swap_cols(&mut self, a: uint, b: uint) {
|
||||
swap(self.col_mut(a),
|
||||
self.col_mut(b));
|
||||
*self.col_mut(a) <-> *self.col_mut(b);
|
||||
}
|
||||
|
||||
#[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)]
|
||||
fn transpose_self(&mut self) {
|
||||
swap(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(1) <-> *self.col_mut(1).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));
|
||||
swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1));
|
||||
*self.col_mut(1).index_mut(0) <-> *self.col_mut(0).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));
|
||||
swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2));
|
||||
*self.col_mut(2).index_mut(0) <-> *self.col_mut(0).index_mut(2);
|
||||
*self.col_mut(2).index_mut(1) <-> *self.col_mut(1).index_mut(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
src/mat4.rs
27
src/mat4.rs
|
@ -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)]
|
||||
fn swap_cols(&mut self, a: uint, b: uint) {
|
||||
swap(self.col_mut(a),
|
||||
self.col_mut(b));
|
||||
*self.col_mut(a) <-> *self.col_mut(b);
|
||||
}
|
||||
|
||||
#[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)]
|
||||
fn transpose_self(&mut self) {
|
||||
swap(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));
|
||||
swap(self.col_mut(0).index_mut(3), self.col_mut(3).index_mut(0));
|
||||
*self.col_mut(0).index_mut(1) <-> *self.col_mut(1).index_mut(0);
|
||||
*self.col_mut(0).index_mut(2) <-> *self.col_mut(2).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));
|
||||
swap(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(0) <-> *self.col_mut(0).index_mut(1);
|
||||
*self.col_mut(1).index_mut(2) <-> *self.col_mut(2).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));
|
||||
swap(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(0) <-> *self.col_mut(0).index_mut(2);
|
||||
*self.col_mut(2).index_mut(1) <-> *self.col_mut(1).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));
|
||||
swap(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(0) <-> *self.col_mut(0).index_mut(3);
|
||||
*self.col_mut(3).index_mut(1) <-> *self.col_mut(1).index_mut(3);
|
||||
*self.col_mut(3).index_mut(2) <-> *self.col_mut(2).index_mut(3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,7 @@ impl<T:Copy> MutableVector<T> for Vec2<T> {
|
|||
|
||||
#[inline(always)]
|
||||
fn swap(&mut self, a: uint, b: uint) {
|
||||
swap(self.index_mut(a),
|
||||
self.index_mut(b));
|
||||
*self.index_mut(a) <-> *self.index_mut(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,7 @@ impl<T:Copy> MutableVector<T> for Vec3<T> {
|
|||
|
||||
#[inline(always)]
|
||||
fn swap(&mut self, a: uint, b: uint) {
|
||||
swap(self.index_mut(a),
|
||||
self.index_mut(b));
|
||||
*self.index_mut(a) <-> *self.index_mut(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,7 @@ impl<T:Copy> MutableVector<T> for Vec4<T> {
|
|||
|
||||
#[inline(always)]
|
||||
fn swap(&mut self, a: uint, b: uint) {
|
||||
swap(self.index_mut(a),
|
||||
self.index_mut(b));
|
||||
*self.index_mut(a) <-> *self.index_mut(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue