From 78da5209e9d3a6baba5816e0c58f785058b09794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lauzier?= Date: Sat, 3 Jul 2021 23:19:07 -0400 Subject: [PATCH] Fix some clippy warnings --- src/base/allocator.rs | 1 + src/base/array_storage.rs | 8 ++------ src/base/blas.rs | 4 ++-- src/base/cg.rs | 4 ++-- src/base/construction.rs | 9 ++++++--- src/base/construction_slice.rs | 4 ++++ src/base/edition.rs | 2 ++ src/base/matrix.rs | 4 ++-- src/base/storage.rs | 1 + src/base/unit.rs | 2 +- src/base/vec_storage.rs | 2 ++ src/geometry/isometry_construction.rs | 2 +- src/geometry/perspective.rs | 2 +- src/geometry/quaternion.rs | 2 +- src/geometry/quaternion_construction.rs | 10 +++++----- src/geometry/reflection.rs | 4 ++-- src/geometry/rotation_specialization.rs | 2 +- src/geometry/transform_ops.rs | 2 +- src/geometry/translation.rs | 2 +- src/geometry/translation_construction.rs | 2 +- src/geometry/unit_complex_construction.rs | 4 ++-- src/linalg/householder.rs | 2 +- src/sparse/cs_matrix.rs | 6 ++++-- src/sparse/cs_matrix_ops.rs | 2 +- src/sparse/cs_matrix_solve.rs | 8 ++++---- src/third_party/alga/alga_dual_quaternion.rs | 8 ++++---- src/third_party/alga/alga_matrix.rs | 6 +++--- src/third_party/alga/alga_point.rs | 2 +- src/third_party/alga/alga_quaternion.rs | 18 +++++++----------- src/third_party/alga/alga_translation.rs | 8 ++++---- src/third_party/alga/alga_unit_complex.rs | 12 ++++++------ 31 files changed, 76 insertions(+), 69 deletions(-) diff --git a/src/base/allocator.rs b/src/base/allocator.rs index 062ffbc2..64871635 100644 --- a/src/base/allocator.rs +++ b/src/base/allocator.rs @@ -40,6 +40,7 @@ pub trait Reallocator: /// Reallocates a buffer of shape `(RTo, CTo)`, possibly reusing a previously allocated buffer /// `buf`. Data stored by `buf` are linearly copied to the output: /// + /// # Safety /// * The copy is performed as if both were just arrays (without a matrix structure). /// * If `buf` is larger than the output size, then extra elements of `buf` are truncated. /// * If `buf` is smaller than the output size, then extra elements of the output are left diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index 00713fb4..611bed93 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -286,11 +286,7 @@ where unsafe fn exhume<'a, 'b>(&'a mut self, mut bytes: &'b mut [u8]) -> Option<&'b mut [u8]> { for element in self.as_mut_slice() { let temp = bytes; - bytes = if let Some(remainder) = element.exhume(temp) { - remainder - } else { - return None; - } + bytes = element.exhume(temp)? } Some(bytes) } @@ -327,7 +323,7 @@ mod rkyv_impl { for ArrayStorage { fn serialize(&self, serializer: &mut S) -> Result { - Ok(self.0.serialize(serializer)?) + self.0.serialize(serializer) } } diff --git a/src/base/blas.rs b/src/base/blas.rs index a6a188bc..b705c6c1 100644 --- a/src/base/blas.rs +++ b/src/base/blas.rs @@ -1388,12 +1388,12 @@ where { work.gemv(T::one(), mid, &rhs.column(0), T::zero()); self.column_mut(0) - .gemv_tr(alpha.inlined_clone(), &rhs, work, beta.inlined_clone()); + .gemv_tr(alpha.inlined_clone(), rhs, work, beta.inlined_clone()); for j in 1..rhs.ncols() { work.gemv(T::one(), mid, &rhs.column(j), T::zero()); self.column_mut(j) - .gemv_tr(alpha.inlined_clone(), &rhs, work, beta.inlined_clone()); + .gemv_tr(alpha.inlined_clone(), rhs, work, beta.inlined_clone()); } } diff --git a/src/base/cg.rs b/src/base/cg.rs index 2b62524b..742824c7 100644 --- a/src/base/cg.rs +++ b/src/base/cg.rs @@ -386,7 +386,7 @@ impl, DimNameDiff::::name()), ) - .tr_dot(&shift); + .tr_dot(shift); let post_translation = self.generic_slice( (0, 0), (DimNameDiff::::name(), DimNameDiff::::name()), @@ -423,7 +423,7 @@ where (D::dim() - 1, 0), (Const::<1>, DimNameDiff::::name()), ); - let n = normalizer.tr_dot(&v); + let n = normalizer.tr_dot(v); if !n.is_zero() { return transform * (v / n); diff --git a/src/base/construction.rs b/src/base/construction.rs index ac9023ec..d5ecc7c1 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -53,7 +53,10 @@ impl OMatrix where DefaultAllocator: Allocator, { - /// Creates a new uninitialized matrix. If the matrix has a compile-time dimension, this panics + /// Creates a new uninitialized matrix. + /// + /// # Safety + /// If the matrix has a compile-time dimension, this panics /// if `nrows != R::to_usize()` or `ncols != C::to_usize()`. #[inline] pub unsafe fn new_uninitialized_generic(nrows: R, ncols: C) -> mem::MaybeUninit { @@ -827,7 +830,7 @@ where Standard: Distribution, { #[inline] - fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> OMatrix { + fn sample(&self, rng: &mut G) -> OMatrix { 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)); @@ -864,7 +867,7 @@ where { /// Generate a uniformly distributed random unit vector. #[inline] - fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Unit> { + fn sample(&self, rng: &mut G) -> Unit> { Unit::new_normalize(OVector::from_distribution_generic( D::name(), Const::<1>, diff --git a/src/base/construction_slice.rs b/src/base/construction_slice.rs index 43f3692b..7094bdca 100644 --- a/src/base/construction_slice.rs +++ b/src/base/construction_slice.rs @@ -10,6 +10,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> { /// Creates, without bound-checking, a matrix slice from an array and with dimensions and strides specified by generic types instances. /// + /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] @@ -59,6 +60,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> { /// Creates, without bound-checking, a matrix slice from an array and with dimensions specified by generic types instances. /// + /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] @@ -146,6 +148,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> { /// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions and strides specified by generic types instances. /// + /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] @@ -217,6 +220,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> { /// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions specified by generic types instances. /// + /// # Safety /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] diff --git a/src/base/edition.rs b/src/base/edition.rs index e7ef00d2..f403f9d3 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -587,6 +587,7 @@ impl> Matrix { /// Inserts `ninsert.value()` columns starting at the `i-th` place of this matrix. /// + /// # Safety /// The added column values are not initialized. #[inline] pub unsafe fn insert_columns_generic_uninitialized( @@ -668,6 +669,7 @@ impl> Matrix { /// Inserts `ninsert.value()` rows at the `i-th` place of this matrix. /// + /// # Safety /// The added rows values are not initialized. /// This is the generic implementation of `.insert_rows(...)` and /// `.insert_fixed_rows(...)` which have nicer API interfaces. diff --git a/src/base/matrix.rs b/src/base/matrix.rs index f2da8a8a..7e5c0ce9 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -336,7 +336,7 @@ mod rkyv_impl { for Matrix { fn serialize(&self, serializer: &mut _S) -> Result { - Ok(self.data.serialize(serializer)?) + self.data.serialize(serializer) } } @@ -1581,7 +1581,7 @@ impl + IsNotStaticOne, S: Storage let dim = DimSum::::from_usize(self.nrows() + 1); let mut res = OMatrix::identity_generic(dim, dim); res.generic_slice_mut::((0, 0), self.data.shape()) - .copy_from(&self); + .copy_from(self); res } } diff --git a/src/base/storage.rs b/src/base/storage.rs index 1eaa9b62..6aa6a7c8 100644 --- a/src/base/storage.rs +++ b/src/base/storage.rs @@ -95,6 +95,7 @@ pub unsafe trait Storage: Debug + Sized { /// Indicates whether this data buffer stores its elements contiguously. /// + /// # Safety /// This method is unsafe because unsafe code relies on this properties to performe /// some low-lever optimizations. unsafe fn is_contiguous(&self) -> bool; diff --git a/src/base/unit.rs b/src/base/unit.rs index 32eff82f..c107bb95 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -95,7 +95,7 @@ mod rkyv_impl { impl, S: Fallible + ?Sized> Serialize for Unit { fn serialize(&self, serializer: &mut S) -> Result { - Ok(self.value.serialize(serializer)?) + self.value.serialize(serializer) } } diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index c312c048..cedfd25f 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -102,6 +102,7 @@ impl VecStorage { /// The underlying mutable data storage. /// + /// # Safety /// This is unsafe because this may cause UB if the size of the vector is changed /// by the user. #[inline] @@ -111,6 +112,7 @@ impl VecStorage { /// Resizes the underlying mutable data storage and unwraps it. /// + /// # Safety /// If `sz` is larger than the current size, additional elements are uninitialized. /// If `sz` is smaller than the current size, additional elements are truncated. #[inline] diff --git a/src/geometry/isometry_construction.rs b/src/geometry/isometry_construction.rs index e13bde29..39a1d763 100644 --- a/src/geometry/isometry_construction.rs +++ b/src/geometry/isometry_construction.rs @@ -86,7 +86,7 @@ where Standard: Distribution + Distribution, { #[inline] - fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Isometry { + fn sample(&self, rng: &mut G) -> Isometry { Isometry::from_parts(rng.gen(), rng.gen()) } } diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index 6ad9707f..359976fe 100644 --- a/src/geometry/perspective.rs +++ b/src/geometry/perspective.rs @@ -288,7 +288,7 @@ where Standard: Distribution, { /// Generate an arbitrary random variate for testing purposes. - fn sample<'a, R: Rng + ?Sized>(&self, r: &'a mut R) -> Perspective3 { + fn sample(&self, r: &mut R) -> Perspective3 { use crate::base::helper; let znear = r.gen(); let zfar = helper::reject_rand(r, |&x: &T| !(x - znear).is_zero()); diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 79fda90a..927a3849 100755 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -139,7 +139,7 @@ mod rkyv_impl { impl, S: Fallible + ?Sized> Serialize for Quaternion { fn serialize(&self, serializer: &mut S) -> Result { - Ok(self.coords.serialize(serializer)?) + self.coords.serialize(serializer) } } diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index f110e3dd..7a681bb2 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -171,7 +171,7 @@ where Standard: Distribution, { #[inline] - fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion { + fn sample(&self, rng: &mut R) -> Quaternion { Quaternion::new(rng.gen(), rng.gen(), rng.gen(), rng.gen()) } } @@ -535,10 +535,10 @@ where SC: Storage, { // TODO: code duplication with Rotation. - let c = na.cross(&nb); + let c = na.cross(nb); if let Some(axis) = Unit::try_new(c, T::default_epsilon()) { - let cos = na.dot(&nb); + let cos = na.dot(nb); // The cosinus may be out of [-1, 1] because of inaccuracies. if cos <= -T::one() { @@ -548,7 +548,7 @@ where } else { Some(Self::from_axis_angle(&axis, cos.acos() * s)) } - } else if na.dot(&nb) < T::zero() { + } else if na.dot(nb) < T::zero() { // PI // // The rotation axis is undefined but the angle not zero. This is not a @@ -860,7 +860,7 @@ where { /// Generate a uniformly distributed random rotation quaternion. #[inline] - fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> UnitQuaternion { + fn sample(&self, rng: &mut R) -> UnitQuaternion { // Ken Shoemake's Subgroup Algorithm // Uniform random rotations. // In D. Kirk, editor, Graphics Gems III, pages 124-132. Academic, New York, 1992. diff --git a/src/geometry/reflection.rs b/src/geometry/reflection.rs index dcc754c2..45b05725 100644 --- a/src/geometry/reflection.rs +++ b/src/geometry/reflection.rs @@ -90,7 +90,7 @@ impl> Reflection { } let m_two: T = crate::convert(-2.0f64); - lhs.gerc(m_two, &work, &self.axis, T::one()); + lhs.gerc(m_two, work, &self.axis, T::one()); } /// Applies the reflection to the rows of `lhs`. @@ -111,6 +111,6 @@ impl> Reflection { } let m_two = sign.scale(crate::convert(-2.0f64)); - lhs.gerc(m_two, &work, &self.axis, sign); + lhs.gerc(m_two, work, &self.axis, sign); } } diff --git a/src/geometry/rotation_specialization.rs b/src/geometry/rotation_specialization.rs index 6c9ecf21..e7f79888 100644 --- a/src/geometry/rotation_specialization.rs +++ b/src/geometry/rotation_specialization.rs @@ -274,7 +274,7 @@ where { /// Generate a uniformly distributed random rotation. #[inline] - fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Rotation2 { + fn sample(&self, rng: &mut R) -> Rotation2 { let twopi = Uniform::new(T::zero(), T::simd_two_pi()); Rotation2::new(rng.sample(twopi)) } diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index efbfa67b..c4ec5cfc 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -124,7 +124,7 @@ md_impl_all!( if C::has_normalizer() { let normalizer = self.matrix().fixed_slice::<1, D>(D, 0); - let n = normalizer.tr_dot(&rhs); + let n = normalizer.tr_dot(rhs); if !n.is_zero() { return transform * (rhs / n); diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index 18fa7e04..c667a512 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -123,7 +123,7 @@ mod rkyv_impl { impl, S: Fallible + ?Sized, const D: usize> Serialize for Translation { fn serialize(&self, serializer: &mut S) -> Result { - Ok(self.vector.serialize(serializer)?) + self.vector.serialize(serializer) } } diff --git a/src/geometry/translation_construction.rs b/src/geometry/translation_construction.rs index c6e9d7d3..5371b648 100644 --- a/src/geometry/translation_construction.rs +++ b/src/geometry/translation_construction.rs @@ -69,7 +69,7 @@ where { /// Generate an arbitrary random variate for testing purposes. #[inline] - fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Translation { + fn sample(&self, rng: &mut G) -> Translation { Translation::from(rng.gen::>()) } } diff --git a/src/geometry/unit_complex_construction.rs b/src/geometry/unit_complex_construction.rs index 16e605f2..a86b2277 100644 --- a/src/geometry/unit_complex_construction.rs +++ b/src/geometry/unit_complex_construction.rs @@ -383,8 +383,8 @@ where SB: Storage, SC: Storage, { - let sang = na.perp(&nb); - let cang = na.dot(&nb); + let sang = na.perp(nb); + let cang = na.dot(nb); Self::from_angle(sang.simd_atan2(cang) * s) } diff --git a/src/linalg/householder.rs b/src/linalg/householder.rs index fbb24e77..9314ee45 100644 --- a/src/linalg/householder.rs +++ b/src/linalg/householder.rs @@ -98,7 +98,7 @@ pub fn clear_row_unchecked( reflection_norm.signum().conjugate(), ); top.columns_range_mut(irow + shift..) - .tr_copy_from(&refl.axis()); + .tr_copy_from(refl.axis()); } else { top.columns_range_mut(irow + shift..).tr_copy_from(&axis); } diff --git a/src/sparse/cs_matrix.rs b/src/sparse/cs_matrix.rs index 74e13719..3a60fb5b 100644 --- a/src/sparse/cs_matrix.rs +++ b/src/sparse/cs_matrix.rs @@ -80,10 +80,12 @@ pub trait CsStorage: for<'a> CsStorageIter<'a, T, R, C> { fn shape(&self) -> (R, C); /// Retrieve the i-th row index of the underlying row index buffer. /// + /// # Safety /// No bound-checking is performed. unsafe fn row_index_unchecked(&self, i: usize) -> usize; /// The i-th value on the contiguous value buffer of this storage. /// + /// # Safety /// No bound-checking is performed. unsafe fn get_value_unchecked(&self, i: usize) -> &T; /// The i-th value on the contiguous value buffer of this storage. @@ -155,7 +157,7 @@ where #[inline] fn column_row_indices(&'a self, j: usize) -> Self::ColumnRowIndices { let rng = self.column_range(j); - self.i[rng.clone()].iter().cloned() + self.i[rng].iter().cloned() } } @@ -489,7 +491,7 @@ where // Sort the index vector. let range = self.data.column_range(j); - self.data.i[range.clone()].sort(); + self.data.i[range.clone()].sort_unstable(); // Permute the values too. for (i, irow) in range.clone().zip(self.data.i[range].iter().cloned()) { diff --git a/src/sparse/cs_matrix_ops.rs b/src/sparse/cs_matrix_ops.rs index e9daa4ae..e03b12a5 100644 --- a/src/sparse/cs_matrix_ops.rs +++ b/src/sparse/cs_matrix_ops.rs @@ -271,7 +271,7 @@ where // Keep the output sorted. let range = res.data.p[j]..nz; - res.data.i[range.clone()].sort(); + res.data.i[range.clone()].sort_unstable(); for p in range { res.data.vals[p] = workspace[res.data.i[p]].inlined_clone() diff --git a/src/sparse/cs_matrix_solve.rs b/src/sparse/cs_matrix_solve.rs index 43c5c2c7..235fcef3 100644 --- a/src/sparse/cs_matrix_solve.rs +++ b/src/sparse/cs_matrix_solve.rs @@ -63,7 +63,7 @@ impl> CsMatrix { let mut column = self.data.column_entries(j); let mut diag_found = false; - while let Some((i, val)) = column.next() { + for (i, val) in &mut column { if i == j { if val.is_zero() { return false; @@ -109,7 +109,7 @@ impl> CsMatrix { let mut column = self.data.column_entries(j); let mut diag = None; - while let Some((i, val)) = column.next() { + for (i, val) in &mut column { if i == j { if val.is_zero() { return false; @@ -151,7 +151,7 @@ impl> CsMatrix { // We don't compute a postordered reach here because it will be sorted after anyway. self.lower_triangular_reach(b, &mut reach); // We sort the reach so the result matrix has sorted indices. - reach.sort(); + reach.sort_unstable(); let mut workspace = unsafe { crate::unimplemented_or_uninitialized_generic!(b.data.shape().0, Const::<1>) }; @@ -167,7 +167,7 @@ impl> CsMatrix { let mut column = self.data.column_entries(j); let mut diag_found = false; - while let Some((i, val)) = column.next() { + for (i, val) in &mut column { if i == j { if val.is_zero() { break; diff --git a/src/third_party/alga/alga_dual_quaternion.rs b/src/third_party/alga/alga_dual_quaternion.rs index d6a5861e..bc07cfa4 100644 --- a/src/third_party/alga/alga_dual_quaternion.rs +++ b/src/third_party/alga/alga_dual_quaternion.rs @@ -267,12 +267,12 @@ impl AffineTransformation> #[inline] fn append_translation(&self, translation: &Self::Translation) -> Self { - self * Self::from_parts(translation.clone(), UnitQuaternion::identity()) + self * Self::from_parts(*translation, UnitQuaternion::identity()) } #[inline] fn prepend_translation(&self, translation: &Self::Translation) -> Self { - Self::from_parts(translation.clone(), UnitQuaternion::identity()) * self + Self::from_parts(*translation, UnitQuaternion::identity()) * self } #[inline] @@ -287,12 +287,12 @@ impl AffineTransformation> #[inline] fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self { - self.clone() + *self } #[inline] fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self { - self.clone() + *self } } diff --git a/src/third_party/alga/alga_matrix.rs b/src/third_party/alga/alga_matrix.rs index 0ddd4fdf..e55ba49e 100644 --- a/src/third_party/alga/alga_matrix.rs +++ b/src/third_party/alga/alga_matrix.rs @@ -272,12 +272,12 @@ where match Self::dimension() { 1 => { - if vs.len() == 0 { + if vs.is_empty() { let _ = f(&Self::canonical_basis_element(0)); } } 2 => { - if vs.len() == 0 { + if vs.is_empty() { let _ = f(&Self::canonical_basis_element(0)) && f(&Self::canonical_basis_element(1)); } else if vs.len() == 1 { @@ -290,7 +290,7 @@ where // Otherwise, nothing. } 3 => { - if vs.len() == 0 { + if vs.is_empty() { let _ = f(&Self::canonical_basis_element(0)) && f(&Self::canonical_basis_element(1)) && f(&Self::canonical_basis_element(2)); diff --git a/src/third_party/alga/alga_point.rs b/src/third_party/alga/alga_point.rs index f1365af4..b1919bb6 100644 --- a/src/third_party/alga/alga_point.rs +++ b/src/third_party/alga/alga_point.rs @@ -23,7 +23,7 @@ impl EuclideanSpace for #[inline] fn coordinates(&self) -> Self::Coordinates { - self.coords.clone() + self.coords } #[inline] diff --git a/src/third_party/alga/alga_quaternion.rs b/src/third_party/alga/alga_quaternion.rs index 0885f44f..7282e0f1 100755 --- a/src/third_party/alga/alga_quaternion.rs +++ b/src/third_party/alga/alga_quaternion.rs @@ -144,11 +144,7 @@ impl NormedSpace for Quaternion { #[inline] fn try_normalize(&self, min_norm: T) -> Option { - if let Some(v) = self.coords.try_normalize(min_norm) { - Some(Self::from(v)) - } else { - None - } + self.coords.try_normalize(min_norm).map(Self::from) } #[inline] @@ -234,17 +230,17 @@ impl AffineTransformation> #[inline] fn decompose(&self) -> (Id, Self, Id, Self) { - (Id::new(), self.clone(), Id::new(), Self::identity()) + (Id::new(), *self, Id::new(), Self::identity()) } #[inline] fn append_translation(&self, _: &Self::Translation) -> Self { - self.clone() + *self } #[inline] fn prepend_translation(&self, _: &Self::Translation) -> Self { - self.clone() + *self } #[inline] @@ -259,12 +255,12 @@ impl AffineTransformation> #[inline] fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self { - self.clone() + *self } #[inline] fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self { - self.clone() + *self } } @@ -278,7 +274,7 @@ impl Similarity> for UnitQuat #[inline] fn rotation(&self) -> Self { - self.clone() + *self } #[inline] diff --git a/src/third_party/alga/alga_translation.rs b/src/third_party/alga/alga_translation.rs index bca6d13f..76a68355 100755 --- a/src/third_party/alga/alga_translation.rs +++ b/src/third_party/alga/alga_translation.rs @@ -79,7 +79,7 @@ impl Transformation) -> SVector { - v.clone() + *v } } @@ -93,7 +93,7 @@ impl ProjectiveTransfor #[inline] fn inverse_transform_vector(&self, v: &SVector) -> SVector { - v.clone() + *v } } @@ -176,7 +176,7 @@ impl AlgaTranslation SVector { - self.vector.clone() + self.vector } #[inline] @@ -186,7 +186,7 @@ impl AlgaTranslation Option { - Some(Self::from(&self.vector * n)) + Some(Self::from(self.vector * n)) } #[inline] diff --git a/src/third_party/alga/alga_unit_complex.rs b/src/third_party/alga/alga_unit_complex.rs index 44dadb42..ca55691b 100755 --- a/src/third_party/alga/alga_unit_complex.rs +++ b/src/third_party/alga/alga_unit_complex.rs @@ -90,17 +90,17 @@ impl AffineTransformation> fo #[inline] fn decompose(&self) -> (Id, Self, Id, Self) { - (Id::new(), self.clone(), Id::new(), Self::identity()) + (Id::new(), *self, Id::new(), Self::identity()) } #[inline] fn append_translation(&self, _: &Self::Translation) -> Self { - self.clone() + *self } #[inline] fn prepend_translation(&self, _: &Self::Translation) -> Self { - self.clone() + *self } #[inline] @@ -115,12 +115,12 @@ impl AffineTransformation> fo #[inline] fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self { - self.clone() + *self } #[inline] fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self { - self.clone() + *self } } @@ -134,7 +134,7 @@ impl Similarity> for UnitComp #[inline] fn rotation(&self) -> Self { - self.clone() + *self } #[inline]