upgrade to newer rust
This commit is contained in:
parent
e2fc8aa764
commit
4e4eb62ffc
@ -40,7 +40,7 @@ macro_rules! dvec_impl(
|
||||
#[inline]
|
||||
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [N] {
|
||||
let len = self.len();
|
||||
self.at.mut_slice_to(len)
|
||||
self.at.slice_to_mut(len)
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ macro_rules! dvec_impl(
|
||||
|
||||
#[inline]
|
||||
unsafe fn unsafe_set(&mut self, i: uint, val: N) {
|
||||
*self.at.as_mut_slice().unsafe_mut_ref(i) = val
|
||||
*self.at.as_mut_slice().unsafe_mut(i) = val
|
||||
}
|
||||
|
||||
}
|
||||
@ -125,8 +125,8 @@ macro_rules! dvec_impl(
|
||||
|
||||
impl<N> IterableMut<N> for $dvec<N> {
|
||||
#[inline]
|
||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
self.as_mut_slice().mut_iter()
|
||||
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
self.as_mut_slice().iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ macro_rules! dvec_impl(
|
||||
fn normalize(&mut self) -> N {
|
||||
let l = Norm::norm(self);
|
||||
|
||||
for n in self.as_mut_slice().mut_iter() {
|
||||
for n in self.as_mut_slice().iter_mut() {
|
||||
*n = *n / l;
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ macro_rules! small_dvec_from_impl (
|
||||
|
||||
let mut at: [N, ..$dim] = [ $( $zeros, )* ];
|
||||
|
||||
for n in at.mut_slice_to(dim).mut_iter() {
|
||||
for n in at.slice_to_mut(dim).iter_mut() {
|
||||
*n = elem.clone();
|
||||
}
|
||||
|
||||
@ -446,7 +446,7 @@ macro_rules! small_dvec_from_impl (
|
||||
// FIXME: not safe.
|
||||
let mut at: [N, ..$dim] = [ $( $zeros, )* ];
|
||||
|
||||
for (curr, other) in vec.iter().zip(at.mut_iter()) {
|
||||
for (curr, other) in vec.iter().zip(at.iter_mut()) {
|
||||
*other = curr.clone();
|
||||
}
|
||||
|
||||
|
@ -20,13 +20,13 @@ macro_rules! at_fast_impl(
|
||||
#[inline]
|
||||
pub unsafe fn at_fast(&self, (i, j): (uint, uint)) -> N {
|
||||
(*mem::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self)
|
||||
.unsafe_ref(i + j * $dim)).clone()
|
||||
.unsafe_get(i + j * $dim)).clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn set_fast(&mut self, (i, j): (uint, uint), val: N) {
|
||||
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim * $dim]>(self)
|
||||
.unsafe_mut_ref(i + j * $dim)) = val
|
||||
.unsafe_mut(i + j * $dim)) = val
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -151,9 +151,9 @@ macro_rules! iterable_mut_impl(
|
||||
($t: ident, $dim: expr) => (
|
||||
impl<N> IterableMut<N> for $t<N> {
|
||||
#[inline]
|
||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
unsafe {
|
||||
mem::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).iter_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,12 +214,12 @@ macro_rules! indexable_impl(
|
||||
|
||||
#[inline]
|
||||
unsafe fn unsafe_at(&self, (i, j): (uint, uint)) -> N {
|
||||
(*mem::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self).unsafe_ref(i + j * $dim)).clone()
|
||||
(*mem::transmute::<&$t<N>, &[N, ..$dim * $dim]>(self).unsafe_get(i + j * $dim)).clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn unsafe_set(&mut self, (i, j): (uint, uint), val: N) {
|
||||
(*mem::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(i + j * $dim)) = val
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -276,7 +276,7 @@ macro_rules! row_impl(
|
||||
fn row(&self, row: uint) -> $tv<N> {
|
||||
let mut res: $tv<N> = Zero::zero();
|
||||
|
||||
for (i, e) in res.mut_iter().enumerate() {
|
||||
for (i, e) in res.iter_mut().enumerate() {
|
||||
*e = self.at((row, i));
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ impl<N: 'static> Iterable<N> for vec::Vec0<N> {
|
||||
|
||||
impl<N: 'static> IterableMut<N> for vec::Vec0<N> {
|
||||
#[inline]
|
||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
unsafe { mem::transmute::<&'l mut vec::Vec0<N>, &'l mut [N, ..0]>(self).iter_mut() }
|
||||
}
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ macro_rules! at_fast_impl(
|
||||
#[inline]
|
||||
pub unsafe fn at_fast(&self, i: uint) -> N {
|
||||
(*mem::transmute::<&$t<N>, &[N, ..$dim]>(self)
|
||||
.unsafe_ref(i)).clone()
|
||||
.unsafe_get(i)).clone()
|
||||
}
|
||||
|
||||
/// Unsafe write access to a vector element by index.
|
||||
#[inline]
|
||||
pub unsafe fn set_fast(&mut self, i: uint, val: N) {
|
||||
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val
|
||||
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut(i)) = val
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -199,12 +199,12 @@ macro_rules! indexable_impl(
|
||||
|
||||
#[inline]
|
||||
unsafe fn unsafe_at(&self, i: uint) -> N {
|
||||
(*mem::transmute::<&$t<N>, &[N, ..$dim]>(self).unsafe_ref(i)).clone()
|
||||
(*mem::transmute::<&$t<N>, &[N, ..$dim]>(self).unsafe_get(i)).clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn unsafe_set(&mut self, i: uint, val: N) {
|
||||
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val
|
||||
(*mem::transmute::<&mut $t<N>, &mut [N, ..$dim]>(self).unsafe_mut(i)) = val
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -258,9 +258,9 @@ macro_rules! iterable_mut_impl(
|
||||
($t: ident, $dim: expr) => (
|
||||
impl<N> IterableMut<N> for $t<N> {
|
||||
#[inline]
|
||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N> {
|
||||
unsafe {
|
||||
mem::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim]>(self).mut_iter()
|
||||
mem::transmute::<&'l mut $t<N>, &'l mut [N, ..$dim]>(self).iter_mut()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ pub trait Iterable<N> {
|
||||
/// Traits of mutable objects which can be iterated through like a vector.
|
||||
pub trait IterableMut<N> {
|
||||
/// Gets a vector-like read-write iterator.
|
||||
fn mut_iter<'l>(&'l mut self) -> MutItems<'l, N>;
|
||||
fn iter_mut<'l>(&'l mut self) -> MutItems<'l, N>;
|
||||
}
|
||||
|
||||
/*
|
||||
|
24
tests/vec.rs
24
tests/vec.rs
@ -14,7 +14,7 @@ macro_rules! test_iterator_impl(
|
||||
|
||||
let nv: $t = v.iter().map(|e| e * n).collect();
|
||||
|
||||
for e in mv.mut_iter() {
|
||||
for e in mv.iter_mut() {
|
||||
*e = *e * n
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ macro_rules! test_commut_dot_impl(
|
||||
for _ in range(0u, 10000) {
|
||||
let v1 : $t = random();
|
||||
let v2 : $t = random();
|
||||
|
||||
|
||||
assert!(na::approx_eq(&na::dot(&v1, &v2), &na::dot(&v2, &v1)));
|
||||
}
|
||||
);
|
||||
@ -39,7 +39,7 @@ macro_rules! test_scalar_op_impl(
|
||||
for _ in range(0u, 10000) {
|
||||
let v1 : $t = random();
|
||||
let n : $n = random();
|
||||
|
||||
|
||||
assert!(na::approx_eq(&((v1 * n) / n), &v1));
|
||||
assert!(na::approx_eq(&((v1 / n) * n), &v1));
|
||||
assert!(na::approx_eq(&((v1 - n) + n), &v1));
|
||||
@ -51,7 +51,7 @@ macro_rules! test_scalar_op_impl(
|
||||
|
||||
v1 = v1 * n;
|
||||
v1 = v1 / n;
|
||||
|
||||
|
||||
assert!(na::approx_eq(&v1, &v0));
|
||||
}
|
||||
);
|
||||
@ -230,22 +230,22 @@ fn test_scalar_op_vec1() {
|
||||
fn test_scalar_op_vec2() {
|
||||
test_scalar_op_impl!(Vec2<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_vec3() {
|
||||
test_scalar_op_impl!(Vec3<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_vec4() {
|
||||
test_scalar_op_impl!(Vec4<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_vec5() {
|
||||
test_scalar_op_impl!(Vec5<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_scalar_op_vec6() {
|
||||
test_scalar_op_impl!(Vec6<f64>, f64);
|
||||
@ -265,22 +265,22 @@ fn test_iterator_vec1() {
|
||||
fn test_iterator_vec2() {
|
||||
test_iterator_impl!(Vec2<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_iterator_vec3() {
|
||||
test_iterator_impl!(Vec3<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_iterator_vec4() {
|
||||
test_iterator_impl!(Vec4<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_iterator_vec5() {
|
||||
test_iterator_impl!(Vec5<f64>, f64);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_iterator_vec6() {
|
||||
test_iterator_impl!(Vec6<f64>, f64);
|
||||
|
Loading…
Reference in New Issue
Block a user