From 062a5126e449dc4a9e61512b15535e08fe686b71 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Thu, 28 Mar 2013 18:24:35 -0700 Subject: [PATCH] Workaround conflicting loans when using util::swap. --- src/lmath.rc | 2 +- src/mat.rs | 2 +- src/mat2.rs | 3 +-- src/mat3.rs | 15 +++++++-------- src/mat4.rs | 27 +++++++++++++-------------- src/vec2.rs | 3 +-- src/vec3.rs | 3 +-- src/vec4.rs | 3 +-- 8 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/lmath.rc b/src/lmath.rc index f5d9b44..4c369a3 100644 --- a/src/lmath.rc +++ b/src/lmath.rc @@ -28,4 +28,4 @@ mod test { #[path = "test_mat.rs" ] mod mat; #[path = "test_quat.rs"] mod quat; #[path = "test_vec.rs" ] mod vec; -} \ No newline at end of file +} diff --git a/src/mat.rs b/src/mat.rs index 5db0a8f..24d0a43 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -300,4 +300,4 @@ pub trait MutableMatrix: Matrix { * Sets the matrix to its transpose */ fn transpose_self(&mut self); -} \ No newline at end of file +} diff --git a/src/mat2.rs b/src/mat2.rs index e26db40..1e4de51 100644 --- a/src/mat2.rs +++ b/src/mat2.rs @@ -220,8 +220,7 @@ impl + Add + Sub + Mul + Div + 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)] diff --git a/src/mat3.rs b/src/mat3.rs index cbf37e9..6837e69 100644 --- a/src/mat3.rs +++ b/src/mat3.rs @@ -488,8 +488,7 @@ impl + Add + Sub + Mul + Div + 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 + Add + Sub + Mul + Div + 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); } } diff --git a/src/mat4.rs b/src/mat4.rs index 70bd87f..5ea6ba0 100644 --- a/src/mat4.rs +++ b/src/mat4.rs @@ -413,8 +413,7 @@ impl + Add + Sub + Mul + Div + 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 + Add + Sub + Mul + Div + 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); } } diff --git a/src/vec2.rs b/src/vec2.rs index 7fa4ba5..771a774 100644 --- a/src/vec2.rs +++ b/src/vec2.rs @@ -85,8 +85,7 @@ impl MutableVector for Vec2 { #[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); } } diff --git a/src/vec3.rs b/src/vec3.rs index c0bf8f7..ac44969 100644 --- a/src/vec3.rs +++ b/src/vec3.rs @@ -88,8 +88,7 @@ impl MutableVector for Vec3 { #[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); } } diff --git a/src/vec4.rs b/src/vec4.rs index 2fae8c4..f9b5c4e 100644 --- a/src/vec4.rs +++ b/src/vec4.rs @@ -87,8 +87,7 @@ impl MutableVector for Vec4 { #[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); } }