diff --git a/src/base/cg.rs b/src/base/cg.rs index ba319c7e..f63cca64 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -79,18 +79,18 @@ impl Matrix3 { /// Can be used to implement "zoom_to" functionality. #[inline] pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector2, pt: &Point2) -> Self { - let _0 = N::zero(); - let _1 = N::one(); + let zero = N::zero(); + let one = N::one(); Matrix3::new( scaling.x, - _0, + zero, pt.x - pt.x * scaling.x, - _0, + zero, scaling.y, pt.y - pt.y * scaling.y, - _0, - _0, - _1, + zero, + zero, + one, ) } } @@ -119,25 +119,25 @@ impl Matrix4 { /// Can be used to implement "zoom_to" functionality. #[inline] pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector3, pt: &Point3) -> Self { - let _0 = N::zero(); - let _1 = N::one(); + let zero = N::zero(); + let one = N::one(); Matrix4::new( scaling.x, - _0, - _0, + zero, + zero, pt.x - pt.x * scaling.x, - _0, + zero, scaling.y, - _0, + zero, pt.y - pt.y * scaling.y, - _0, - _0, + zero, + zero, scaling.z, pt.z - pt.z * scaling.z, - _0, - _0, - _0, - _1, + zero, + zero, + zero, + one, ) } diff --git a/src/base/construction.rs b/src/base/construction.rs index 7f293554..ac6eed1e 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -196,7 +196,7 @@ where SB: Storage, { assert!(rows.len() > 0, "At least one row must be given."); - let nrows = R::try_to_usize().unwrap_or(rows.len()); + let nrows = R::try_to_usize().unwrap_or_else(|| rows.len()); let ncols = rows[0].len(); assert!( rows.len() == nrows, @@ -803,8 +803,8 @@ where { #[inline] fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> MatrixMN { - let nrows = R::try_to_usize().unwrap_or(rng.gen_range(0, 10)); - let ncols = C::try_to_usize().unwrap_or(rng.gen_range(0, 10)); + let nrows = R::try_to_usize().unwrap_or_else(|| rng.gen_range(0, 10)); + let ncols = C::try_to_usize().unwrap_or_else(|| rng.gen_range(0, 10)); MatrixMN::from_fn_generic(R::from_usize(nrows), C::from_usize(ncols), |_, _| rng.gen()) } diff --git a/src/base/iter.rs b/src/base/iter.rs index 304bfa93..2823b39e 100644 --- a/src/base/iter.rs +++ b/src/base/iter.rs @@ -48,11 +48,11 @@ macro_rules! iterator { }; $Name { - ptr: ptr, + ptr, inner_ptr: ptr, inner_end, size: shape.0.value() * shape.1.value(), - strides: strides, + strides, _phantoms: PhantomData, } } diff --git a/src/base/matrix_slice.rs b/src/base/matrix_slice.rs index 21bcc349..ac1fbfd6 100644 --- a/src/base/matrix_slice.rs +++ b/src/base/matrix_slice.rs @@ -39,9 +39,9 @@ macro_rules! slice_storage_impl( CStride: Dim { $T { - ptr: ptr, - shape: shape, - strides: strides, + ptr, + shape, + strides, _phantoms: PhantomData } } diff --git a/src/base/unit.rs b/src/base/unit.rs index 9a32dd2f..5afa006b 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -134,9 +134,9 @@ impl Unit { #[inline] pub fn renormalize_fast(&mut self) { let sq_norm = self.value.norm_squared(); - let _3: T::Norm = crate::convert(3.0); - let _0_5: T::Norm = crate::convert(0.5); - self.value.scale_mut(_0_5 * (_3 - sq_norm)); + let three: T::Norm = crate::convert(3.0); + let half: T::Norm = crate::convert(0.5); + self.value.scale_mut(half * (three - sq_norm)); } } diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index 0c8d769f..63f00636 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -285,13 +285,13 @@ where // Robust matrix to quaternion transformation. // See https://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion let tr = rotmat[(0, 0)] + rotmat[(1, 1)] + rotmat[(2, 2)]; - let _0_25: N = crate::convert(0.25); + let quarter: N = crate::convert(0.25); let res = tr.simd_gt(N::zero()).if_else3( || { let denom = (tr + N::one()).simd_sqrt() * crate::convert(2.0); Quaternion::new( - _0_25 * denom, + quarter * denom, (rotmat[(2, 1)] - rotmat[(1, 2)]) / denom, (rotmat[(0, 2)] - rotmat[(2, 0)]) / denom, (rotmat[(1, 0)] - rotmat[(0, 1)]) / denom, @@ -305,7 +305,7 @@ where * crate::convert(2.0); Quaternion::new( (rotmat[(2, 1)] - rotmat[(1, 2)]) / denom, - _0_25 * denom, + quarter * denom, (rotmat[(0, 1)] + rotmat[(1, 0)]) / denom, (rotmat[(0, 2)] + rotmat[(2, 0)]) / denom, ) @@ -320,7 +320,7 @@ where Quaternion::new( (rotmat[(0, 2)] - rotmat[(2, 0)]) / denom, (rotmat[(0, 1)] + rotmat[(1, 0)]) / denom, - _0_25 * denom, + quarter * denom, (rotmat[(1, 2)] + rotmat[(2, 1)]) / denom, ) }, @@ -333,7 +333,7 @@ where (rotmat[(1, 0)] - rotmat[(0, 1)]) / denom, (rotmat[(0, 2)] + rotmat[(2, 0)]) / denom, (rotmat[(1, 2)] + rotmat[(2, 1)]) / denom, - _0_25 * denom, + quarter * denom, ) }, );