From b805f9d829699a4895260eca7bd0f3c6516ce913 Mon Sep 17 00:00:00 2001 From: Jameson Ernst Date: Sat, 28 Feb 2015 16:48:58 -0800 Subject: [PATCH 1/3] Fix macros for nightly --- src/structs/dmat.rs | 4 ++-- src/structs/dvec_macros.rs | 4 ++-- src/structs/mat_macros.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/structs/dmat.rs b/src/structs/dmat.rs index 93a49071..ab3049f0 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -618,13 +618,13 @@ impl> ApproxEq for DMat { #[inline] fn approx_eq_eps(&self, other: &DMat, epsilon: &N) -> bool { - let zip = self.mij.iter().zip(other.mij.iter()); + let mut zip = self.mij.iter().zip(other.mij.iter()); zip.all(|(a, b)| ApproxEq::approx_eq_eps(a, b, epsilon)) } #[inline] fn approx_eq_ulps(&self, other: &DMat, ulps: u32) -> bool { - let zip = self.mij.iter().zip(other.mij.iter()); + let mut zip = self.mij.iter().zip(other.mij.iter()); zip.all(|(a, b)| ApproxEq::approx_eq_ulps(a, b, ulps)) } } diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index f108f090..2624d7b8 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -319,13 +319,13 @@ macro_rules! dvec_impl( #[inline] fn approx_eq_eps(&self, other: &$dvec, epsilon: &N) -> bool { - let zip = self.as_slice().iter().zip(other.as_slice().iter()); + let mut zip = self.as_slice().iter().zip(other.as_slice().iter()); zip.all(|(a, b)| ApproxEq::approx_eq_eps(a, b, epsilon)) } #[inline] fn approx_eq_ulps(&self, other: &$dvec, ulps: u32) -> bool { - let zip = self.as_slice().iter().zip(other.as_slice().iter()); + let mut zip = self.as_slice().iter().zip(other.as_slice().iter()); zip.all(|(a, b)| ApproxEq::approx_eq_ulps(a, b, ulps)) } } diff --git a/src/structs/mat_macros.rs b/src/structs/mat_macros.rs index 5f5bcac1..064ce573 100644 --- a/src/structs/mat_macros.rs +++ b/src/structs/mat_macros.rs @@ -646,13 +646,13 @@ macro_rules! approx_eq_impl( #[inline] fn approx_eq_eps(&self, other: &$t, epsilon: &N) -> bool { - let zip = self.iter().zip(other.iter()); + let mut zip = self.iter().zip(other.iter()); zip.all(|(a, b)| ApproxEq::approx_eq_eps(a, b, epsilon)) } #[inline] fn approx_eq_ulps(&self, other: &$t, ulps: u32) -> bool { - let zip = self.iter().zip(other.iter()); + let mut zip = self.iter().zip(other.iter()); zip.all(|(a, b)| ApproxEq::approx_eq_ulps(a, b, ulps)) } } From 744e9782fcf7ef869a9d8d838dd263afa2b8f65a Mon Sep 17 00:00:00 2001 From: Jameson Ernst Date: Sat, 28 Feb 2015 16:49:12 -0800 Subject: [PATCH 2/3] Fix deprecated suffixes in tests --- tests/mat.rs | 14 +++++++------- tests/quat.rs | 10 +++++----- tests/vec.rs | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/mat.rs b/tests/mat.rs index b107d504..764b9c75 100644 --- a/tests/mat.rs +++ b/tests/mat.rs @@ -7,7 +7,7 @@ use na::{Vec1, Vec3, Mat1, Mat2, Mat3, Mat4, Mat5, Mat6, Rot3, Persp3, PerspMat3 macro_rules! test_inv_mat_impl( ($t: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let randmat : $t = random(); match na::inv(&randmat) { @@ -20,7 +20,7 @@ macro_rules! test_inv_mat_impl( macro_rules! test_transpose_mat_impl( ($t: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let randmat : $t = random(); assert!(na::transpose(&na::transpose(&randmat)) == randmat); @@ -30,7 +30,7 @@ macro_rules! test_transpose_mat_impl( macro_rules! test_qr_impl( ($t: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let randmat : $t = random(); let (q, r) = na::qr(&randmat); @@ -44,7 +44,7 @@ macro_rules! test_qr_impl( // NOTE: deactivated untile we get a better convergence rate. // macro_rules! test_eigen_qr_impl( // ($t: ty) => { -// for _ in (0us .. 10000) { +// for _ in (0usize .. 10000) { // let randmat : $t = random(); // // Make it symetric so that we can recompose the matrix to test at the end. // let randmat = na::transpose(&randmat) * randmat; @@ -126,7 +126,7 @@ fn test_inv_mat6() { #[test] fn test_rotation2() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let randmat: na::Rot2 = na::one(); let ang = Vec1::new(na::abs(&random::()) % ::pi()); @@ -143,7 +143,7 @@ fn test_index_mat2() { #[test] fn test_inv_rotation3() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let randmat: Rot3 = na::one(); let dir: Vec3 = random(); let ang = na::normalize(&dir) * (na::abs(&random::()) % ::pi()); @@ -251,7 +251,7 @@ fn test_dmat_from_vec() { /* FIXME: review qr decomposition to make it work with DMat. #[test] fn test_qr() { - for _ in (0us .. 10) { + for _ in (0usize .. 10) { let dim1: usize = random(); let dim2: usize = random(); let rows = min(40, max(dim1, dim2)); diff --git a/tests/quat.rs b/tests/quat.rs index 2751fbbe..00375dcf 100644 --- a/tests/quat.rs +++ b/tests/quat.rs @@ -6,7 +6,7 @@ use rand::random; #[test] fn test_quat_as_mat() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let axis_angle: Vec3 = random(); assert!(na::approx_eq(&UnitQuat::new(axis_angle).to_rot(), &Rot3::new(axis_angle))) @@ -15,7 +15,7 @@ fn test_quat_as_mat() { #[test] fn test_quat_mul_vec_or_pnt_as_mat() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let axis_angle: Vec3 = random(); let vec: Vec3 = random(); let pnt: Pnt3 = random(); @@ -32,7 +32,7 @@ fn test_quat_mul_vec_or_pnt_as_mat() { #[test] fn test_quat_div_quat() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let axis_angle1: Vec3 = random(); let axis_angle2: Vec3 = random(); @@ -48,7 +48,7 @@ fn test_quat_div_quat() { #[test] fn test_quat_to_axis_angle() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let axis_angle: Vec3 = random(); let q = UnitQuat::new(axis_angle); @@ -60,7 +60,7 @@ fn test_quat_to_axis_angle() { #[test] fn test_quat_euler_angles() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let angles: Vec3 = random(); let q = UnitQuat::new_with_euler_angles(angles.x, angles.y, angles.z); diff --git a/tests/vec.rs b/tests/vec.rs index 087026e2..60642842 100644 --- a/tests/vec.rs +++ b/tests/vec.rs @@ -6,7 +6,7 @@ use na::{Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6, Mat3, Iterable, IterableMut}; macro_rules! test_iterator_impl( ($t: ty, $n: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let v: $t = random(); let mut mv: $t = v.clone(); let n: $n = random(); @@ -24,7 +24,7 @@ macro_rules! test_iterator_impl( macro_rules! test_commut_dot_impl( ($t: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let v1 : $t = random(); let v2 : $t = random(); @@ -35,7 +35,7 @@ macro_rules! test_commut_dot_impl( macro_rules! test_scalar_op_impl( ($t: ty, $n: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let v1 : $t = random(); let n : $n = random(); @@ -58,7 +58,7 @@ macro_rules! test_scalar_op_impl( macro_rules! test_basis_impl( ($t: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { na::canonical_basis(|e1: $t| { na::canonical_basis(|e2: $t| { assert!(e1 == e2 || na::approx_eq(&na::dot(&e1, &e2), &na::zero())); @@ -76,7 +76,7 @@ macro_rules! test_basis_impl( macro_rules! test_subspace_basis_impl( ($t: ty) => ( - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let v : $t = random(); let v1 = na::normalize(&v); @@ -100,7 +100,7 @@ macro_rules! test_subspace_basis_impl( #[test] fn test_cross_vec3() { - for _ in (0us .. 10000) { + for _ in (0usize .. 10000) { let v1 : Vec3 = random(); let v2 : Vec3 = random(); let v3 : Vec3 = na::cross(&v1, &v2); From caca330995604e7bfcb88f8af56d66396d1cd1da Mon Sep 17 00:00:00 2001 From: Jameson Ernst Date: Sun, 1 Mar 2015 12:41:13 -0800 Subject: [PATCH 3/3] Fix deprecated closure syntax --- src/structs/dvec_macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index 2624d7b8..79d6fc05 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -106,7 +106,7 @@ macro_rules! dvec_impl( /// Builds a vector filled with random values. #[inline] pub fn new_random(dim: usize) -> $dvec { - $dvec::from_fn(dim, |&: _| rand::random()) + $dvec::from_fn(dim, |_| rand::random()) } }