Fix index operator overloads
This commit is contained in:
parent
ce0a6bcd02
commit
1342d52bfa
10 changed files with 18 additions and 18 deletions
|
@ -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] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,10 +558,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] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,10 +501,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] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,10 +392,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, 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] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub impl Vec4: Index<uint, float> {
|
||||||
fn index(i: uint) -> float {
|
fn index(i: uint) -> float {
|
||||||
unsafe { do buf_as_slice(
|
unsafe { do buf_as_slice(
|
||||||
transmute::<*Vec4, *float>(
|
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<uint, Vec4> {
|
||||||
fn index(i: uint) -> Vec4 {
|
fn index(i: uint) -> Vec4 {
|
||||||
unsafe { do buf_as_slice(
|
unsafe { do buf_as_slice(
|
||||||
transmute::<*Mat4, *Vec4>(
|
transmute::<*Mat4, *Vec4>(
|
||||||
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
|
to_unsafe_ptr(&self)), 4) |slice| { slice[*i] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub impl VecBufSlice: Index<uint, float> {
|
||||||
fn index(i: uint) -> float unsafe {
|
fn index(i: uint) -> float unsafe {
|
||||||
do vec::raw::buf_as_slice(
|
do vec::raw::buf_as_slice(
|
||||||
transmute::<*VecBufSlice, *float>(
|
transmute::<*VecBufSlice, *float>(
|
||||||
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
|
to_unsafe_ptr(&self)), 4) |slice| { slice[*i] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub impl<T:Copy Num> Vec4<T> {
|
||||||
fn index(i: uint) -> T {
|
fn index(i: uint) -> T {
|
||||||
unsafe { do buf_as_slice(
|
unsafe { do buf_as_slice(
|
||||||
transmute::<*Vec4<T>, *T>(
|
transmute::<*Vec4<T>, *T>(
|
||||||
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
|
to_unsafe_ptr(&self)), 4) |slice| { slice[*i] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,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] } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,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] } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,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] } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue