From 1342d52bfa38de2d516057ea80f6b44b1a7968b9 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 29 Mar 2013 09:14:20 +1100 Subject: [PATCH] Fix index operator overloads --- src/mat2.rs | 4 ++-- src/mat3.rs | 4 ++-- src/mat4.rs | 4 ++-- src/quat.rs | 4 ++-- src/test/performance/matrix_mul.rs | 4 ++-- src/test/performance/vector_index_operator.rs | 2 +- src/test/performance/vector_map_fold.rs | 2 +- src/vec2.rs | 4 ++-- src/vec3.rs | 4 ++-- src/vec4.rs | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mat2.rs b/src/mat2.rs index aaf1384..84bbef7 100644 --- a/src/mat2.rs +++ b/src/mat2.rs @@ -380,10 +380,10 @@ impl + Add + Sub + Mul + Div + N impl Index> for Mat2 { #[inline(always)] - fn index(&self, i: uint) -> Vec2 { + fn index(&self, i: &uint) -> Vec2 { unsafe { do buf_as_slice( transmute::<*Mat2, *Vec2>( - to_unsafe_ptr(self)), 2) |slice| { slice[i] } + to_unsafe_ptr(self)), 2) |slice| { slice[*i] } } } } diff --git a/src/mat3.rs b/src/mat3.rs index 67cf467..b8dad31 100644 --- a/src/mat3.rs +++ b/src/mat3.rs @@ -558,10 +558,10 @@ impl + Add + Sub + Mul + Div + N impl Index> for Mat3 { #[inline(always)] - fn index(&self, i: uint) -> Vec3 { + fn index(&self, i: &uint) -> Vec3 { unsafe { do buf_as_slice( transmute::<*Mat3, *Vec3>( - to_unsafe_ptr(self)), 3) |slice| { slice[i] } + to_unsafe_ptr(self)), 3) |slice| { slice[*i] } } } } diff --git a/src/mat4.rs b/src/mat4.rs index 5f3c16a..7d549f5 100644 --- a/src/mat4.rs +++ b/src/mat4.rs @@ -501,10 +501,10 @@ impl + Add + Sub + Mul + Div + N impl Index> for Mat4 { #[inline(always)] - fn index(&self, i: uint) -> Vec4 { + fn index(&self, i: &uint) -> Vec4 { unsafe { do buf_as_slice( transmute::<*Mat4, *Vec4>( - to_unsafe_ptr(self)), 4) |slice| { slice[i] } + to_unsafe_ptr(self)), 4) |slice| { slice[*i] } } } } diff --git a/src/quat.rs b/src/quat.rs index 5ce31e4..ac9c95d 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -392,10 +392,10 @@ impl + Add + Sub + Mul + Div + N impl Index for Quat { #[inline(always)] - fn index(&self, i: uint) -> T { + fn index(&self, i: &uint) -> T { unsafe { do buf_as_slice( transmute::<*Quat, *T>( - to_unsafe_ptr(self)), 4) |slice| { slice[i] } + to_unsafe_ptr(self)), 4) |slice| { slice[*i] } } } } diff --git a/src/test/performance/matrix_mul.rs b/src/test/performance/matrix_mul.rs index 7b740a4..99dc2a1 100644 --- a/src/test/performance/matrix_mul.rs +++ b/src/test/performance/matrix_mul.rs @@ -99,7 +99,7 @@ pub impl Vec4: Index { fn index(i: uint) -> float { unsafe { do buf_as_slice( transmute::<*Vec4, *float>( - to_unsafe_ptr(&self)), 4) |slice| { slice[i] } + to_unsafe_ptr(&self)), 4) |slice| { slice[*i] } } } } @@ -191,7 +191,7 @@ pub impl Mat4: Index { fn index(i: uint) -> Vec4 { unsafe { do buf_as_slice( transmute::<*Mat4, *Vec4>( - to_unsafe_ptr(&self)), 4) |slice| { slice[i] } + to_unsafe_ptr(&self)), 4) |slice| { slice[*i] } } } } diff --git a/src/test/performance/vector_index_operator.rs b/src/test/performance/vector_index_operator.rs index d0960ff..51626a0 100644 --- a/src/test/performance/vector_index_operator.rs +++ b/src/test/performance/vector_index_operator.rs @@ -51,7 +51,7 @@ pub impl VecBufSlice: Index { fn index(i: uint) -> float unsafe { do vec::raw::buf_as_slice( transmute::<*VecBufSlice, *float>( - to_unsafe_ptr(&self)), 4) |slice| { slice[i] } + to_unsafe_ptr(&self)), 4) |slice| { slice[*i] } } } diff --git a/src/test/performance/vector_map_fold.rs b/src/test/performance/vector_map_fold.rs index 61d56c6..35d4eb7 100644 --- a/src/test/performance/vector_map_fold.rs +++ b/src/test/performance/vector_map_fold.rs @@ -28,7 +28,7 @@ pub impl Vec4 { fn index(i: uint) -> T { unsafe { do buf_as_slice( transmute::<*Vec4, *T>( - to_unsafe_ptr(&self)), 4) |slice| { slice[i] } + to_unsafe_ptr(&self)), 4) |slice| { slice[*i] } } } diff --git a/src/vec2.rs b/src/vec2.rs index 3e8ea5f..06f0925 100644 --- a/src/vec2.rs +++ b/src/vec2.rs @@ -68,8 +68,8 @@ impl Vector2 for Vec2 { impl Index for Vec2 { #[inline(always)] - fn index(&self, i: uint) -> T { - unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[i] } } + fn index(&self, i: &uint) -> T { + unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[*i] } } } } diff --git a/src/vec3.rs b/src/vec3.rs index ecd6cef..a35b1c2 100644 --- a/src/vec3.rs +++ b/src/vec3.rs @@ -70,8 +70,8 @@ impl Vector3 for Vec3 { impl Index for Vec3 { #[inline(always)] - fn index(&self, i: uint) -> T { - unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } } + fn index(&self, i: &uint) -> T { + unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[*i] } } } } diff --git a/src/vec4.rs b/src/vec4.rs index c7aa91f..7f2496a 100644 --- a/src/vec4.rs +++ b/src/vec4.rs @@ -68,8 +68,8 @@ impl Vector4 for Vec4 { impl Index for Vec4 { #[inline(always)] - fn index(&self, i: uint) -> T { - unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } } + fn index(&self, i: &uint) -> T { + unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[*i] } } } }