Re-fix index operators

This commit is contained in:
Brendan Zabarauskas 2013-03-29 13:47:19 +11:00
parent 0285bf5098
commit 4cefbf763c
7 changed files with 14 additions and 14 deletions

View file

@ -380,10 +380,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec2<T>> for Mat2<T> { impl<T:Copy> Index<uint, Vec2<T>> for Mat2<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: uint) -> Vec2<T> { fn index(&self, i: &uint) -> Vec2<T> {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Mat2<T>, *Vec2<T>>( transmute::<*Mat2<T>, *Vec2<T>>(
to_unsafe_ptr(self)), 2) |slice| { slice[i] } to_unsafe_ptr(self)), 2) |slice| { slice[*i] }
} }
} }
} }

View file

@ -556,10 +556,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec3<T>> for Mat3<T> { impl<T:Copy> Index<uint, Vec3<T>> for Mat3<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: uint) -> Vec3<T> { fn index(&self, i: &uint) -> Vec3<T> {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Mat3<T>, *Vec3<T>>( transmute::<*Mat3<T>, *Vec3<T>>(
to_unsafe_ptr(self)), 3) |slice| { slice[i] } to_unsafe_ptr(self)), 3) |slice| { slice[*i] }
} }
} }
} }

View file

@ -499,10 +499,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec4<T>> for Mat4<T> { impl<T:Copy> Index<uint, Vec4<T>> for Mat4<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: uint) -> Vec4<T> { fn index(&self, i: &uint) -> Vec4<T> {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Mat4<T>, *Vec4<T>>( transmute::<*Mat4<T>, *Vec4<T>>(
to_unsafe_ptr(self)), 4) |slice| { slice[i] } to_unsafe_ptr(self)), 4) |slice| { slice[*i] }
} }
} }
} }

View file

@ -391,10 +391,10 @@ pub impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T>
impl<T:Copy> Index<uint, T> for Quat<T> { impl<T:Copy> Index<uint, T> for Quat<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: uint) -> T { fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Quat<T>, *T>( transmute::<*Quat<T>, *T>(
to_unsafe_ptr(self)), 4) |slice| { slice[i] } to_unsafe_ptr(self)), 4) |slice| { slice[*i] }
} }
} }
} }

View file

@ -67,8 +67,8 @@ impl<T> Vector2<T> for Vec2<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec2<T> { impl<T:Copy + Eq> Index<uint, T> for Vec2<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: uint) -> T { fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[i] } } unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[*i] } }
} }
} }

View file

@ -69,8 +69,8 @@ impl<T> Vector3<T> for Vec3<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec3<T> { impl<T:Copy + Eq> Index<uint, T> for Vec3<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: uint) -> T { fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } } unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[*i] } }
} }
} }

View file

@ -67,8 +67,8 @@ impl<T> Vector4<T> for Vec4<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec4<T> { impl<T:Copy + Eq> Index<uint, T> for Vec4<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: uint) -> T { fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } } unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[*i] } }
} }
} }