From 4e4eb62ffce0b9986c4b1924533ef0a85b3bca81 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Wed, 22 Oct 2014 13:35:17 +0200 Subject: [PATCH] upgrade to newer rust --- src/structs/dvec_macros.rs | 14 +++++++------- src/structs/mat_macros.rs | 14 +++++++------- src/structs/spec/vec0.rs | 2 +- src/structs/vec_macros.rs | 12 ++++++------ src/traits/structure.rs | 2 +- tests/vec.rs | 24 ++++++++++++------------ 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index bba4d156..0d7cfe4e 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -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 IterableMut for $dvec { #[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(); } diff --git a/src/structs/mat_macros.rs b/src/structs/mat_macros.rs index c09a6b7a..702bd3ae 100644 --- a/src/structs/mat_macros.rs +++ b/src/structs/mat_macros.rs @@ -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, ..$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, &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 IterableMut for $t { #[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, &'l mut [N, ..$dim * $dim]>(self).mut_iter() + mem::transmute::<&'l mut $t, &'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, ..$dim * $dim]>(self).unsafe_ref(i + j * $dim)).clone() + (*mem::transmute::<&$t, &[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, &mut [N, ..$dim * $dim]>(self).unsafe_mut_ref(i + j * $dim)) = val + (*mem::transmute::<&mut $t, &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 { let mut res: $tv = Zero::zero(); - for (i, e) in res.mut_iter().enumerate() { + for (i, e) in res.iter_mut().enumerate() { *e = self.at((row, i)); } diff --git a/src/structs/spec/vec0.rs b/src/structs/spec/vec0.rs index 4a3ea40d..a7fea6ed 100644 --- a/src/structs/spec/vec0.rs +++ b/src/structs/spec/vec0.rs @@ -45,7 +45,7 @@ impl Iterable for vec::Vec0 { impl IterableMut for vec::Vec0 { #[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, &'l mut [N, ..0]>(self).iter_mut() } } } diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index cdb5bce2..5145723b 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -42,13 +42,13 @@ macro_rules! at_fast_impl( #[inline] pub unsafe fn at_fast(&self, i: uint) -> N { (*mem::transmute::<&$t, &[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, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val + (*mem::transmute::<&mut $t, &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, ..$dim]>(self).unsafe_ref(i)).clone() + (*mem::transmute::<&$t, &[N, ..$dim]>(self).unsafe_get(i)).clone() } #[inline] unsafe fn unsafe_set(&mut self, i: uint, val: N) { - (*mem::transmute::<&mut $t, &mut [N, ..$dim]>(self).unsafe_mut_ref(i)) = val + (*mem::transmute::<&mut $t, &mut [N, ..$dim]>(self).unsafe_mut(i)) = val } } ) @@ -258,9 +258,9 @@ macro_rules! iterable_mut_impl( ($t: ident, $dim: expr) => ( impl IterableMut for $t { #[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, &'l mut [N, ..$dim]>(self).mut_iter() + mem::transmute::<&'l mut $t, &'l mut [N, ..$dim]>(self).iter_mut() } } } diff --git a/src/traits/structure.rs b/src/traits/structure.rs index 3f8a5911..62ee0b7d 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -139,7 +139,7 @@ pub trait Iterable { /// Traits of mutable objects which can be iterated through like a vector. pub trait IterableMut { /// 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>; } /* diff --git a/tests/vec.rs b/tests/vec.rs index 0c3054a2..42ab35bb 100644 --- a/tests/vec.rs +++ b/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); } - + #[test] fn test_scalar_op_vec3() { test_scalar_op_impl!(Vec3, f64); } - + #[test] fn test_scalar_op_vec4() { test_scalar_op_impl!(Vec4, f64); } - + #[test] fn test_scalar_op_vec5() { test_scalar_op_impl!(Vec5, f64); } - + #[test] fn test_scalar_op_vec6() { test_scalar_op_impl!(Vec6, f64); @@ -265,22 +265,22 @@ fn test_iterator_vec1() { fn test_iterator_vec2() { test_iterator_impl!(Vec2, f64); } - + #[test] fn test_iterator_vec3() { test_iterator_impl!(Vec3, f64); } - + #[test] fn test_iterator_vec4() { test_iterator_impl!(Vec4, f64); } - + #[test] fn test_iterator_vec5() { test_iterator_impl!(Vec5, f64); } - + #[test] fn test_iterator_vec6() { test_iterator_impl!(Vec6, f64);