Remove usages of 'to_unsafe_ptr'

This commit is contained in:
Brendan Zabarauskas 2013-03-29 22:09:15 +11:00
parent e8e1fb49c5
commit fdb8a73555
7 changed files with 11 additions and 58 deletions

View file

@ -1,6 +1,5 @@
use core::cast::transmute;
use core::cmp::Eq;
use core::ptr::to_unsafe_ptr;
use core::sys::size_of;
use core::util::swap;
use core::vec::raw::buf_as_slice;
@ -200,11 +199,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)]
fn to_ptr(&self) -> *T {
unsafe {
transmute::<*Mat2<T>, *T>(
to_unsafe_ptr(self)
)
}
unsafe { transmute(self) }
}
}
@ -381,10 +376,7 @@ 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> {
#[inline(always)]
fn index(&self, i: &uint) -> Vec2<T> {
unsafe { do buf_as_slice(
transmute::<*Mat2<T>, *Vec2<T>>(
to_unsafe_ptr(self)), 2) |slice| { slice[*i] }
}
unsafe { do buf_as_slice(transmute(self), 2) |slice| { slice[*i] } }
}
}

View file

@ -1,6 +1,5 @@
use core::cast::transmute;
use core::cmp::Eq;
use core::ptr::to_unsafe_ptr;
use core::sys::size_of;
use core::vec::raw::buf_as_slice;
@ -239,11 +238,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)]
fn to_ptr(&self) -> *T {
unsafe {
transmute::<*Mat3<T>, *T>(
to_unsafe_ptr(self)
)
}
unsafe { transmute(self) }
}
}
@ -557,10 +552,7 @@ 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> {
#[inline(always)]
fn index(&self, i: &uint) -> Vec3<T> {
unsafe { do buf_as_slice(
transmute::<*Mat3<T>, *Vec3<T>>(
to_unsafe_ptr(self)), 3) |slice| { slice[*i] }
}
unsafe { do buf_as_slice(transmute(self), 3) |slice| { slice[*i] } }
}
}

View file

@ -1,6 +1,5 @@
use core::cast::transmute;
use core::cmp::Eq;
use core::ptr::to_unsafe_ptr;
use core::sys::size_of;
use core::vec::raw::buf_as_slice;
@ -323,11 +322,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)]
fn to_ptr(&self) -> *T {
unsafe {
transmute::<*Mat4<T>, *T>(
to_unsafe_ptr(self)
)
}
unsafe { transmute(self) }
}
}
@ -500,10 +495,7 @@ 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> {
#[inline(always)]
fn index(&self, i: &uint) -> Vec4<T> {
unsafe { do buf_as_slice(
transmute::<*Mat4<T>, *Vec4<T>>(
to_unsafe_ptr(self)), 4) |slice| { slice[*i] }
}
unsafe { do buf_as_slice(transmute(self), 4) |slice| { slice[*i] } }
}
}

View file

@ -9,7 +9,6 @@
use core::cast::transmute;
use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr;
use core::vec::raw::buf_as_slice;
use std::cmp::{FuzzyEq, FUZZY_EPSILON};
@ -353,11 +352,7 @@ pub impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T>
*/
#[inline(always)]
fn to_ptr(&self) -> *T {
unsafe {
transmute::<*Quat<T>, *T>(
to_unsafe_ptr(self)
)
}
unsafe { transmute(self) }
}
/**
@ -392,10 +387,7 @@ 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> {
#[inline(always)]
fn index(&self, i: &uint) -> T {
unsafe { do buf_as_slice(
transmute::<*Quat<T>, *T>(
to_unsafe_ptr(self)), 4) |slice| { slice[*i] }
}
unsafe { do buf_as_slice(transmute(self), 4) |slice| { slice[*i] } }
}
}

View file

@ -1,6 +1,5 @@
use core::cast::transmute;
use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr;
use core::sys::size_of;
use core::vec::raw::buf_as_slice;
@ -50,11 +49,7 @@ impl<T:Copy + Eq> Vector<T> for Vec2<T> {
#[inline(always)]
fn to_ptr(&self) -> *T {
unsafe {
transmute::<*Vec2<T>, *T>(
to_unsafe_ptr(self)
)
}
unsafe { transmute(self) }
}
}

View file

@ -1,6 +1,5 @@
use core::cast::transmute;
use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr;
use core::sys::size_of;
use core::vec::raw::buf_as_slice;
@ -52,11 +51,7 @@ impl<T:Copy + Eq> Vector<T> for Vec3<T> {
#[inline(always)]
fn to_ptr(&self) -> *T {
unsafe {
transmute::<*Vec3<T>, *T>(
to_unsafe_ptr(self)
)
}
unsafe { transmute(self) }
}
}

View file

@ -1,6 +1,5 @@
use core::cast::transmute;
use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr;
use core::sys::size_of;
use core::vec::raw::buf_as_slice;
@ -50,11 +49,7 @@ impl<T:Copy + Eq> Vector<T> for Vec4<T> {
#[inline(always)]
fn to_ptr(&self) -> *T {
unsafe {
transmute::<*Vec4<T>, *T>(
to_unsafe_ptr(self)
)
}
unsafe { transmute(self) }
}
}