Merge pull request #8 from alexanderchr/master
std::cast::transmute -> std::mem::transmute
This commit is contained in:
commit
eb6370f78e
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#![allow(missing_doc)] // we allow missing to avoid having to document the mij components.
|
#![allow(missing_doc)] // we allow missing to avoid having to document the mij components.
|
||||||
|
|
||||||
use std::cast;
|
use std::mem;
|
||||||
use std::num::{One, Zero};
|
use std::num::{One, Zero};
|
||||||
use traits::operations::ApproxEq;
|
use traits::operations::ApproxEq;
|
||||||
use std::slice::{Items, MutItems};
|
use std::slice::{Items, MutItems};
|
||||||
|
|
|
@ -19,13 +19,13 @@ macro_rules! at_fast_impl(
|
||||||
impl<N: Clone> $t<N> {
|
impl<N: Clone> $t<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn at_fast(&self, (i, j): (uint, uint)) -> N {
|
pub unsafe fn at_fast(&self, (i, j): (uint, uint)) -> N {
|
||||||
(*cast::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self)
|
(*mem::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self)
|
||||||
.unsafe_ref(i + j * $dim)).clone()
|
.unsafe_ref(i + j * $dim)).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_fast(&mut self, (i, j): (uint, uint), val: N) {
|
pub unsafe fn set_fast(&mut self, (i, j): (uint, uint), val: N) {
|
||||||
(*cast::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self)
|
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self)
|
||||||
.unsafe_mut_ref(i + j * $dim)) = val
|
.unsafe_mut_ref(i + j * $dim)) = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ macro_rules! iterable_impl(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn iter<'l>(&'l self) -> Items<'l, N> {
|
fn iter<'l>(&'l self) -> Items<'l, N> {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&'l $t<N>, &'l [N, ..$dim * $dim]>(self).iter()
|
mem::transmute::<&'l $t<N>, &'l [N, ..$dim * $dim]>(self).iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ macro_rules! iterable_mut_impl(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim * $dim]>(self).mut_iter()
|
mem::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim * $dim]>(self).mut_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,33 +174,33 @@ macro_rules! indexable_impl(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn at(&self, (i, j): (uint, uint)) -> N {
|
fn at(&self, (i, j): (uint, uint)) -> N {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self)[i + j * $dim].clone()
|
mem::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self)[i + j * $dim].clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set(&mut self, (i, j): (uint, uint), val: N) {
|
fn set(&mut self, (i, j): (uint, uint), val: N) {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self)[i + j * $dim] = val
|
mem::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self)[i + j * $dim] = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn swap(&mut self, (i1, j1): (uint, uint), (i2, j2): (uint, uint)) {
|
fn swap(&mut self, (i1, j1): (uint, uint), (i2, j2): (uint, uint)) {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self)
|
mem::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self)
|
||||||
.swap(i1 + j1 * $dim, i2 + j2 * $dim)
|
.swap(i1 + j1 * $dim, i2 + j2 * $dim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn unsafe_at(&self, (i, j): (uint, uint)) -> N {
|
unsafe fn unsafe_at(&self, (i, j): (uint, uint)) -> N {
|
||||||
(*cast::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self).unsafe_ref(i + j * $dim)).clone()
|
(*mem::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self).unsafe_ref(i + j * $dim)).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn unsafe_set(&mut self, (i, j): (uint, uint), val: N) {
|
unsafe fn unsafe_set(&mut self, (i, j): (uint, uint), val: N) {
|
||||||
(*cast::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self).unsafe_mut_ref(i + j * $dim)) = val
|
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self).unsafe_mut_ref(i + j * $dim)) = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::cast;
|
use std::mem;
|
||||||
use std::num::{Zero, One, Float, Bounded};
|
use std::num::{Zero, One, Float, Bounded};
|
||||||
use std::slice::{Items, MutItems};
|
use std::slice::{Items, MutItems};
|
||||||
use std::iter::{Iterator, FromIterator};
|
use std::iter::{Iterator, FromIterator};
|
||||||
|
@ -50,14 +50,14 @@ impl<N> vec::Vec0<N> {
|
||||||
impl<N> Iterable<N> for vec::Vec0<N> {
|
impl<N> Iterable<N> for vec::Vec0<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn iter<'l>(&'l self) -> Items<'l, N> {
|
fn iter<'l>(&'l self) -> Items<'l, N> {
|
||||||
unsafe { cast::transmute::<&'l vec::Vec0<N>, &'l [N, ..0]>(self).iter() }
|
unsafe { mem::transmute::<&'l vec::Vec0<N>, &'l [N, ..0]>(self).iter() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N> IterableMut<N> for vec::Vec0<N> {
|
impl<N> IterableMut<N> for vec::Vec0<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||||
unsafe { cast::transmute::<&'l mut vec::Vec0<N>, &'l mut [N, ..0]>(self).mut_iter() }
|
unsafe { mem::transmute::<&'l mut vec::Vec0<N>, &'l mut [N, ..0]>(self).mut_iter() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#![allow(missing_doc)] // we allow missing to avoid having to document the vector components.
|
#![allow(missing_doc)] // we allow missing to avoid having to document the vector components.
|
||||||
|
|
||||||
use std::cast;
|
use std::mem;
|
||||||
use std::num::{Zero, One, Float, Bounded};
|
use std::num::{Zero, One, Float, Bounded};
|
||||||
use std::slice::{Items, MutItems};
|
use std::slice::{Items, MutItems};
|
||||||
use std::iter::{Iterator, FromIterator};
|
use std::iter::{Iterator, FromIterator};
|
||||||
|
|
|
@ -21,14 +21,14 @@ macro_rules! at_fast_impl(
|
||||||
/// Unsafe read access to a vector element by index.
|
/// Unsafe read access to a vector element by index.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn at_fast(&self, i: uint) -> N {
|
pub unsafe fn at_fast(&self, i: uint) -> N {
|
||||||
(*cast::transmute::<&$t<N>, &[N, ..$dim]>(self)
|
(*mem::transmute::<&$t<N>, &[N, ..$dim]>(self)
|
||||||
.unsafe_ref(i)).clone()
|
.unsafe_ref(i)).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unsafe write access to a vector element by index.
|
/// Unsafe write access to a vector element by index.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_fast(&mut self, i: uint, val: N) {
|
pub unsafe fn set_fast(&mut self, i: uint, val: N) {
|
||||||
(*cast::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val
|
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -154,32 +154,32 @@ macro_rules! indexable_impl(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn at(&self, i: uint) -> N {
|
fn at(&self, i: uint) -> N {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&$t<N>, &[N, ..$dim]>(self)[i].clone()
|
mem::transmute::<&$t<N>, &[N, ..$dim]>(self)[i].clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set(&mut self, i: uint, val: N) {
|
fn set(&mut self, i: uint, val: N) {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self)[i] = val
|
mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self)[i] = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn swap(&mut self, i1: uint, i2: uint) {
|
fn swap(&mut self, i1: uint, i2: uint) {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).swap(i1, i2)
|
mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).swap(i1, i2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn unsafe_at(&self, i: uint) -> N {
|
unsafe fn unsafe_at(&self, i: uint) -> N {
|
||||||
(*cast::transmute::<&$t<N>, &[N, ..$dim]>(self).unsafe_ref(i)).clone()
|
(*mem::transmute::<&$t<N>, &[N, ..$dim]>(self).unsafe_ref(i)).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn unsafe_set(&mut self, i: uint, val: N) {
|
unsafe fn unsafe_set(&mut self, i: uint, val: N) {
|
||||||
(*cast::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val
|
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -206,7 +206,7 @@ macro_rules! iterable_impl(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn iter<'l>(&'l self) -> Items<'l, N> {
|
fn iter<'l>(&'l self) -> Items<'l, N> {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&'l $t<N>, &'l [N, ..$dim]>(self).iter()
|
mem::transmute::<&'l $t<N>, &'l [N, ..$dim]>(self).iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ macro_rules! iterable_mut_impl(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||||
unsafe {
|
unsafe {
|
||||||
cast::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim]>(self).mut_iter()
|
mem::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim]>(self).mut_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue