From c3f869e017bbf6752e2fde527c17703af5418160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Violeta=20Hern=C3=A1ndez?= Date: Fri, 16 Jul 2021 01:53:28 -0500 Subject: [PATCH] Checkpoint #8 --- nalgebra-sparse/src/convert/impl_std_ops.rs | 12 +- src/base/construction_slice.rs | 20 ++-- src/base/conversion.rs | 115 ++++++-------------- src/base/default_allocator.rs | 4 +- src/base/matrix.rs | 8 +- src/base/statistics.rs | 10 +- src/base/unit.rs | 8 +- src/base/vec_storage.rs | 6 +- src/geometry/dual_quaternion.rs | 6 +- src/geometry/point.rs | 34 +++--- src/geometry/point_construction.rs | 21 ++-- src/geometry/point_conversion.rs | 14 +-- src/geometry/point_ops.rs | 4 +- src/geometry/point_simba.rs | 7 +- src/geometry/quaternion.rs | 6 +- src/third_party/mint/mint_quaternion.rs | 2 +- 16 files changed, 108 insertions(+), 169 deletions(-) diff --git a/nalgebra-sparse/src/convert/impl_std_ops.rs b/nalgebra-sparse/src/convert/impl_std_ops.rs index ba4c015b..4e2a039f 100644 --- a/nalgebra-sparse/src/convert/impl_std_ops.rs +++ b/nalgebra-sparse/src/convert/impl_std_ops.rs @@ -6,11 +6,9 @@ use nalgebra::storage::Storage; use nalgebra::{ClosedAdd, DMatrix, Dim, Matrix, Scalar}; use num_traits::Zero; -impl<'a, T, R, C, S> From<&'a Matrix> for CooMatrix +impl<'a, T, R: Dim, C: Dim, S> From<&'a Matrix> for CooMatrix where T: Scalar + Zero, - R: Dim, - C: Dim, S: Storage, { fn from(matrix: &'a Matrix) -> Self { @@ -45,11 +43,9 @@ where } } -impl<'a, T, R, C, S> From<&'a Matrix> for CsrMatrix +impl<'a, T, R: Dim, C: Dim, S> From<&'a Matrix> for CsrMatrix where T: Scalar + Zero, - R: Dim, - C: Dim, S: Storage, { fn from(matrix: &'a Matrix) -> Self { @@ -84,11 +80,9 @@ where } } -impl<'a, T, R, C, S> From<&'a Matrix> for CscMatrix +impl<'a, T, R: Dim, C: Dim, S> From<&'a Matrix> for CscMatrix where T: Scalar + Zero, - R: Dim, - C: Dim, S: Storage, { fn from(matrix: &'a Matrix) -> Self { diff --git a/src/base/construction_slice.rs b/src/base/construction_slice.rs index 7094bdca..650fbfd0 100644 --- a/src/base/construction_slice.rs +++ b/src/base/construction_slice.rs @@ -1,13 +1,11 @@ use crate::base::dimension::{Const, Dim, DimName, Dynamic}; use crate::base::matrix_slice::{SliceStorage, SliceStorageMut}; -use crate::base::{MatrixSlice, MatrixSliceMutMN, Scalar}; +use crate::base::{MatrixSlice, MatrixSliceMutMN}; use num_rational::Ratio; /// # Creating matrix slices from `&[T]` -impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> - MatrixSlice<'a, T, R, C, RStride, CStride> -{ +impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSlice<'a, T, R, C, RStride, CStride> { /// Creates, without bound-checking, a matrix slice from an array and with dimensions and strides specified by generic types instances. /// /// # Safety @@ -57,7 +55,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> { +impl<'a, T, 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 @@ -87,7 +85,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> { macro_rules! impl_constructors( ($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => { - impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixSlice<'a, T, $($Dims),*> { + impl<'a, T, $($DimIdent: $DimBound),*> MatrixSlice<'a, T, $($Dims),*> { /// Creates a new matrix slice from the given data array. /// /// Panics if `data` does not contain enough elements. @@ -103,7 +101,7 @@ macro_rules! impl_constructors( } } - impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixSlice<'a, T, $($Dims,)* Dynamic, Dynamic> { + impl<'a, T, $($DimIdent: $DimBound, )*> MatrixSlice<'a, T, $($Dims,)* Dynamic, Dynamic> { /// Creates a new matrix slice with the specified strides from the given data array. /// /// Panics if `data` does not contain enough elements. @@ -143,7 +141,7 @@ impl_constructors!(Dynamic, Dynamic; nrows, ncols); /// # Creating mutable matrix slices from `&mut [T]` -impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> +impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSliceMutMN<'a, T, R, C, RStride, CStride> { /// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions and strides specified by generic types instances. @@ -217,7 +215,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> { +impl<'a, T, 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 @@ -247,7 +245,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> { macro_rules! impl_constructors_mut( ($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => { - impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, T, $($Dims),*> { + impl<'a, T, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, T, $($Dims),*> { /// Creates a new mutable matrix slice from the given data array. /// /// Panics if `data` does not contain enough elements. @@ -263,7 +261,7 @@ macro_rules! impl_constructors_mut( } } - impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, T, $($Dims,)* Dynamic, Dynamic> { + impl<'a, T, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, T, $($Dims,)* Dynamic, Dynamic> { /// Creates a new mutable matrix slice with the specified strides from the given data array. /// /// Panics if `data` does not contain enough elements. diff --git a/src/base/conversion.rs b/src/base/conversion.rs index 1efb9a91..071679f0 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -104,14 +104,14 @@ impl<'a, T: Scalar, R: Dim, C: Dim, S: StorageMut> IntoIterator } } -impl From<[T; D]> for SVector { +impl From<[T; D]> for SVector { #[inline] fn from(arr: [T; D]) -> Self { unsafe { Self::from_data_statically_unchecked(ArrayStorage([arr; 1])) } } } -impl From> for [T; D] { +impl From> for [T; D] { #[inline] fn from(vec: SVector) -> Self { // TODO: unfortunately, we must clone because we can move out of an array. @@ -119,7 +119,7 @@ impl From> for [T; D] { } } -impl From<[T; D]> for RowSVector +impl From<[T; D]> for RowSVector where Const: IsNotStaticOne, { @@ -129,7 +129,7 @@ where } } -impl From> for [T; D] +impl From> for [T; D] where Const: IsNotStaticOne, { @@ -142,7 +142,7 @@ where macro_rules! impl_from_into_asref_1D( ($(($NRows: ident, $NCols: ident) => $SZ: expr);* $(;)*) => {$( impl AsRef<[T; $SZ]> for Matrix - where T: Scalar, + where S: ContiguousStorage { #[inline] fn as_ref(&self) -> &[T; $SZ] { @@ -153,7 +153,7 @@ macro_rules! impl_from_into_asref_1D( } impl AsMut<[T; $SZ]> for Matrix - where T: Scalar, + where S: ContiguousStorageMut { #[inline] fn as_mut(&mut self) -> &mut [T; $SZ] { @@ -180,14 +180,14 @@ impl_from_into_asref_1D!( (U13, U1) => 13; (U14, U1) => 14; (U15, U1) => 15; (U16, U1) => 16; ); -impl From<[[T; R]; C]> for SMatrix { +impl From<[[T; R]; C]> for SMatrix { #[inline] fn from(arr: [[T; R]; C]) -> Self { unsafe { Self::from_data_statically_unchecked(ArrayStorage(arr)) } } } -impl From> for [[T; R]; C] { +impl From> for [[T; R]; C] { #[inline] fn from(vec: SMatrix) -> Self { vec.data.0 @@ -201,7 +201,7 @@ macro_rules! impl_from_into_asref_borrow_2D( ($NRows: ty, $NCols: ty) => ($SZRows: expr, $SZCols: expr); $Ref:ident.$ref:ident(), $Mut:ident.$mut:ident() ) => { - impl $Ref<[[T; $SZRows]; $SZCols]> for Matrix + impl $Ref<[[T; $SZRows]; $SZCols]> for Matrix where S: ContiguousStorage { #[inline] fn $ref(&self) -> &[[T; $SZRows]; $SZCols] { @@ -211,7 +211,7 @@ macro_rules! impl_from_into_asref_borrow_2D( } } - impl $Mut<[[T; $SZRows]; $SZCols]> for Matrix + impl $Mut<[[T; $SZRows]; $SZCols]> for Matrix where S: ContiguousStorageMut { #[inline] fn $mut(&mut self) -> &mut [[T; $SZRows]; $SZCols] { @@ -242,13 +242,9 @@ impl_from_into_asref_borrow_2D!( (U6, U2) => (6, 2); (U6, U3) => (6, 3); (U6, U4) => (6, 4); (U6, U5) => (6, 5); (U6, U6) => (6, 6); ); -impl<'a, T, RStride, CStride, const R: usize, const C: usize> +impl<'a, T: Clone, RStride: Dim, CStride: Dim, const R: usize, const C: usize> From, Const, RStride, CStride>> for Matrix, Const, ArrayStorage> -where - T: Scalar, - RStride: Dim, - CStride: Dim, { fn from(matrix_slice: MatrixSlice<'a, T, Const, Const, RStride, CStride>) -> Self { matrix_slice.into_owned() @@ -256,13 +252,9 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, C, RStride, CStride> From> +impl<'a, T: Clone, C: Dim, RStride: Dim, CStride: Dim> + From> for Matrix> -where - T: Scalar, - C: Dim, - RStride: Dim, - CStride: Dim, { fn from(matrix_slice: MatrixSlice<'a, T, Dynamic, C, RStride, CStride>) -> Self { matrix_slice.into_owned() @@ -270,26 +262,18 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, R, RStride, CStride> From> +impl<'a, T: Clone, R: DimName, RStride: Dim, CStride: Dim> + From> for Matrix> -where - T: Scalar, - R: DimName, - RStride: Dim, - CStride: Dim, { fn from(matrix_slice: MatrixSlice<'a, T, R, Dynamic, RStride, CStride>) -> Self { matrix_slice.into_owned() } } -impl<'a, T, RStride, CStride, const R: usize, const C: usize> +impl<'a, T: Clone, RStride: Dim, CStride: Dim, const R: usize, const C: usize> From, Const, RStride, CStride>> for Matrix, Const, ArrayStorage> -where - T: Scalar, - RStride: Dim, - CStride: Dim, { fn from(matrix_slice: MatrixSliceMut<'a, T, Const, Const, RStride, CStride>) -> Self { matrix_slice.into_owned() @@ -297,13 +281,9 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, C, RStride, CStride> From> +impl<'a, T: Clone, C: Dim, RStride: Dim, CStride: Dim> + From> for Matrix> -where - T: Scalar, - C: Dim, - RStride: Dim, - CStride: Dim, { fn from(matrix_slice: MatrixSliceMut<'a, T, Dynamic, C, RStride, CStride>) -> Self { matrix_slice.into_owned() @@ -311,29 +291,18 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T, R, RStride, CStride> From> +impl<'a, T: Clone, R: DimName, RStride: Dim, CStride: Dim> + From> for Matrix> -where - T: Scalar, - R: DimName, - RStride: Dim, - CStride: Dim, { fn from(matrix_slice: MatrixSliceMut<'a, T, R, Dynamic, RStride, CStride>) -> Self { matrix_slice.into_owned() } } -impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a Matrix> - for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride> +impl<'a, T, R: Dim, C: Dim, RSlice: Dim, CSlice: Dim, RStride: Dim, CStride: Dim, S> + From<&'a Matrix> for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride> where - T: Scalar, - R: Dim, - C: Dim, - RSlice: Dim, - CSlice: Dim, - RStride: Dim, - CStride: Dim, S: Storage, ShapeConstraint: DimEq + DimEq @@ -361,16 +330,9 @@ where } } -impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix> - for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride> +impl<'a, T, R: Dim, C: Dim, RSlice: Dim, CSlice: Dim, RStride: Dim, CStride: Dim, S> + From<&'a mut Matrix> for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride> where - T: Scalar, - R: Dim, - C: Dim, - RSlice: Dim, - CSlice: Dim, - RStride: Dim, - CStride: Dim, S: Storage, ShapeConstraint: DimEq + DimEq @@ -398,16 +360,9 @@ where } } -impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix> - for MatrixSliceMut<'a, T, RSlice, CSlice, RStride, CStride> +impl<'a, T: Dim, R: Dim, C: Dim, RSlice: Dim, CSlice: Dim, RStride: Dim, CStride: Dim, S> + From<&'a mut Matrix> for MatrixSliceMut<'a, T, RSlice, CSlice, RStride, CStride> where - T: Scalar, - R: Dim, - C: Dim, - RSlice: Dim, - CSlice: Dim, - RStride: Dim, - CStride: Dim, S: StorageMut, ShapeConstraint: DimEq + DimEq @@ -436,15 +391,15 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -impl<'a, T: Scalar> From> for DVector { +impl<'a, T> From> for DVector { #[inline] fn from(vec: Vec) -> Self { Self::from_vec(vec) } } -impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorage> - From<&'a Matrix> for &'a [T] +impl<'a, T, R: Dim, C: Dim, S: ContiguousStorage> From<&'a Matrix> + for &'a [T] { #[inline] fn from(matrix: &'a Matrix) -> Self { @@ -452,8 +407,8 @@ impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorage> } } -impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorageMut> - From<&'a mut Matrix> for &'a mut [T] +impl<'a, T, R: Dim, C: Dim, S: ContiguousStorageMut> From<&'a mut Matrix> + for &'a mut [T] { #[inline] fn from(matrix: &'a mut Matrix) -> Self { @@ -461,27 +416,27 @@ impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorageMut> } } -impl<'a, T: Scalar + Copy> From<&'a [T]> for DVectorSlice<'a, T> { +impl<'a, T> From<&'a [T]> for DVectorSlice<'a, T> { #[inline] fn from(slice: &'a [T]) -> Self { Self::from_slice(slice, slice.len()) } } -impl<'a, T: Scalar> From> for &'a [T] { +impl<'a, T> From> for &'a [T] { fn from(vec: DVectorSlice<'a, T>) -> &'a [T] { vec.data.into_slice() } } -impl<'a, T: Scalar + Copy> From<&'a mut [T]> for DVectorSliceMut<'a, T> { +impl<'a, T> From<&'a mut [T]> for DVectorSliceMut<'a, T> { #[inline] fn from(slice: &'a mut [T]) -> Self { Self::from_slice(slice, slice.len()) } } -impl<'a, T: Scalar> From> for &'a mut [T] { +impl<'a, T> From> for &'a mut [T] { fn from(vec: DVectorSliceMut<'a, T>) -> &'a mut [T] { vec.data.into_slice_mut() } diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index 4991312e..0cd6874b 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -181,11 +181,9 @@ impl Allocator for DefaultAllocator { * */ // Anything -> Static × Static -impl +impl Reallocator, Const> for DefaultAllocator where - RFrom: Dim, - CFrom: Dim, Self: Allocator, { #[inline] diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 51c8b945..299e57e1 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -591,7 +591,7 @@ impl> Matrix { #[inline] #[must_use] #[allow(clippy::should_implement_trait)] - pub fn eq(&self, other: &Matrix) -> bool + pub fn eq(&self, other: &Matrix) -> bool where T: PartialEq, SB: Storage, @@ -2244,11 +2244,9 @@ where } } -impl Hash for Matrix +impl Hash for Matrix where - T: Scalar + Hash, - R: Dim, - C: Dim, + T: Hash, S: Storage, { fn hash(&self, state: &mut H) { diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 23ab524e..0e0cfc6f 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -25,11 +25,11 @@ impl> Matrix { for i in 0..ncols.value() { // TODO: avoid bound checking of column. unsafe { - *res.get_unchecked_mut((0, i)) =MaybeUninit::new( f(self.column(i))); + *res.get_unchecked_mut((0, i)) = MaybeUninit::new(f(self.column(i))); } } - res + unsafe { res.assume_init() } } /// Returns a column vector where each element is the result of the application of `f` on the @@ -69,13 +69,11 @@ impl> Matrix { where DefaultAllocator: Allocator, { - let mut res = init; - for i in 0..self.ncols() { - f(&mut res, self.column(i)) + f(&mut init, self.column(i)) } - res + init } } diff --git a/src/base/unit.rs b/src/base/unit.rs index 96864ec3..8346d2ed 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -10,7 +10,7 @@ use abomonation::Abomonation; use crate::allocator::Allocator; use crate::base::DefaultAllocator; -use crate::storage::Storage; +use crate::storage::{Owned, Storage}; use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealField}; /// A wrapper that ensures the underlying algebraic entity has a unit norm. @@ -126,7 +126,7 @@ where impl Eq for Unit> where - T: Eq, + T: Eq, R: Dim, C: Dim, S: Storage, @@ -344,6 +344,7 @@ where T: From<[::Element; 2]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, + Owned: Clone, { #[inline] fn from(arr: [Unit>; 2]) -> Self { @@ -360,6 +361,7 @@ where T: From<[::Element; 4]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, + Owned: Clone, { #[inline] fn from(arr: [Unit>; 4]) -> Self { @@ -378,6 +380,7 @@ where T: From<[::Element; 8]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, + Owned: Clone, { #[inline] fn from(arr: [Unit>; 8]) -> Self { @@ -400,6 +403,7 @@ where T: From<[::Element; 16]>, T::Element: Scalar, DefaultAllocator: Allocator + Allocator, + Owned: Clone, { #[inline] fn from(arr: [Unit>; 16]) -> Self { diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index 04423beb..ee57218f 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -194,7 +194,7 @@ where #[inline] fn clone_owned(&self) -> Owned - where + where T:Clone, DefaultAllocator: InnerAllocator, { self.clone() @@ -243,7 +243,7 @@ where #[inline] fn clone_owned(&self) -> Owned - where + where T:Clone, DefaultAllocator: InnerAllocator, { self.clone() @@ -414,7 +414,7 @@ impl<'a, T: 'a + Copy, R: Dim> Extend<&'a T> for VecStorage { } } -impl Extend> for VecStorage +impl Extend> for VecStorage where SV: Storage, ShapeConstraint: SameNumberOfRows, diff --git a/src/geometry/dual_quaternion.rs b/src/geometry/dual_quaternion.rs index 01ea9dcc..ba12cb6f 100644 --- a/src/geometry/dual_quaternion.rs +++ b/src/geometry/dual_quaternion.rs @@ -46,16 +46,16 @@ pub struct DualQuaternion { pub dual: Quaternion, } -impl Eq for DualQuaternion {} +impl Eq for DualQuaternion {} -impl PartialEq for DualQuaternion { +impl PartialEq for DualQuaternion { #[inline] fn eq(&self, right: &Self) -> bool { self.real == right.real && self.dual == right.dual } } -impl Default for DualQuaternion { +impl Default for DualQuaternion { fn default() -> Self { Self { real: Quaternion::default(), diff --git a/src/geometry/point.rs b/src/geometry/point.rs index d3e52d5e..4317a62c 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -14,10 +14,11 @@ use abomonation::Abomonation; use simba::simd::SimdPartialOrd; +use crate::allocator::InnerAllocator; use crate::base::allocator::Allocator; use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; use crate::base::iter::{MatrixIter, MatrixIterMut}; -use crate::base::{Const, DefaultAllocator, OVector, Scalar}; +use crate::base::{Const, DefaultAllocator, OVector}; use crate::storage::Owned; /// A point in an euclidean space. @@ -43,13 +44,13 @@ use crate::storage::Owned; #[derive(Debug, Clone)] pub struct OPoint where - DefaultAllocator: Allocator, + DefaultAllocator: InnerAllocator, { /// The coordinates of this point, i.e., the shift from the origin. pub coords: OVector, } -impl hash::Hash for OPoint +impl hash::Hash for OPoint where DefaultAllocator: Allocator, { @@ -58,7 +59,7 @@ where } } -impl Copy for OPoint +impl Copy for OPoint where DefaultAllocator: Allocator, OVector: Copy, @@ -66,7 +67,7 @@ where } #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Zeroable for OPoint +unsafe impl bytemuck::Zeroable for OPoint where OVector: bytemuck::Zeroable, DefaultAllocator: Allocator, @@ -74,7 +75,7 @@ where } #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Pod for OPoint +unsafe impl bytemuck::Pod for OPoint where T: Copy, OVector: bytemuck::Pod, @@ -83,7 +84,7 @@ where } #[cfg(feature = "serde-serialize-no-std")] -impl Serialize for OPoint +impl Serialize for OPoint where DefaultAllocator: Allocator, >::Buffer: Serialize, @@ -97,7 +98,7 @@ where } #[cfg(feature = "serde-serialize-no-std")] -impl<'a, T: Scalar + Deserialize<'a>, D: DimName> Deserialize<'a> for OPoint +impl<'a, T: Deserialize<'a>, D: DimName> Deserialize<'a> for OPoint where DefaultAllocator: Allocator, >::Buffer: Deserialize<'a>, @@ -115,7 +116,6 @@ where #[cfg(feature = "abomonation-serialize")] impl Abomonation for OPoint where - T: Scalar, OVector: Abomonation, DefaultAllocator: Allocator, { @@ -132,7 +132,7 @@ where } } -impl OPoint +impl OPoint where DefaultAllocator: Allocator, { @@ -150,8 +150,8 @@ where /// ``` #[inline] #[must_use] - pub fn map T2>(&self, f: F) -> OPoint - where + pub fn map T2>(&self, f: F) -> OPoint + where T:Clone, DefaultAllocator: Allocator, { self.coords.map(f).into() @@ -314,7 +314,7 @@ where } } -impl AbsDiffEq for OPoint +impl AbsDiffEq for OPoint where T::Epsilon: Copy, DefaultAllocator: Allocator, @@ -332,7 +332,7 @@ where } } -impl RelativeEq for OPoint +impl RelativeEq for OPoint where T::Epsilon: Copy, DefaultAllocator: Allocator, @@ -354,7 +354,7 @@ where } } -impl UlpsEq for OPoint +impl UlpsEq for OPoint where T::Epsilon: Copy, DefaultAllocator: Allocator, @@ -415,7 +415,7 @@ where /* * inf/sup */ -impl OPoint +impl OPoint where DefaultAllocator: Allocator, { @@ -447,7 +447,7 @@ where * Display * */ -impl fmt::Display for OPoint +impl fmt::Display for OPoint where DefaultAllocator: Allocator, { diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index a4da45b4..317eb8e7 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -1,3 +1,5 @@ +use std::mem::MaybeUninit; + #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -20,17 +22,14 @@ use simba::scalar::{ClosedDiv, SupersetOf}; use crate::geometry::Point; /// # Other construction methods -impl OPoint +impl OPoint where DefaultAllocator: Allocator, { /// Creates a new point with uninitialized coordinates. #[inline] - pub unsafe fn new_uninitialized() -> Self { - Self::from(crate::unimplemented_or_uninitialized_generic!( - D::name(), - Const::<1> - )) + pub unsafe fn new_uninitialized() -> OPoint, D> { + OPoint::from(OVector::new_uninitialized_generic(D::name(), Const::<1>)) } /// Creates a new point with all coordinates equal to zero. @@ -130,7 +129,7 @@ where /// let pt2 = pt.cast::(); /// assert_eq!(pt2, Point2::new(1.0f32, 2.0)); /// ``` - pub fn cast(self) -> OPoint + pub fn cast(self) -> OPoint where OPoint: SupersetOf, DefaultAllocator: Allocator, @@ -160,7 +159,7 @@ where } #[cfg(feature = "rand-no-std")] -impl Distribution> for Standard +impl Distribution> for Standard where Standard: Distribution, DefaultAllocator: Allocator, @@ -176,7 +175,7 @@ where impl Arbitrary for OPoint where DefaultAllocator: Allocator, - crate:: base::storage::Owned: Send, + crate::base::storage::Owned: Send, { #[inline] fn arbitrary(g: &mut Gen) -> Self { @@ -192,7 +191,7 @@ where // NOTE: the impl for Point1 is not with the others so that we // can add a section with the impl block comment. /// # Construction from individual components -impl Point1 { +impl Point1 { /// Initializes this point from its components. /// /// # Example @@ -211,7 +210,7 @@ impl Point1 { } macro_rules! componentwise_constructors_impl( ($($doc: expr; $Point: ident, $Vector: ident, $($args: ident:$irow: expr),*);* $(;)*) => {$( - impl $Point { + impl $Point { #[doc = "Initializes this point from its components."] #[doc = "# Example\n```"] #[doc = $doc] diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index 62528641..423b4d4f 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -20,8 +20,7 @@ use crate::{DimName, OPoint}; impl SubsetOf> for OPoint where - T1: Scalar, - T2: Scalar + SupersetOf, + T2: SupersetOf, DefaultAllocator: Allocator + Allocator, { #[inline] @@ -45,7 +44,6 @@ where impl SubsetOf>> for OPoint where D: DimNameAdd, - T1: Scalar, T2: Scalar + Zero + One + ClosedDiv + SupersetOf, DefaultAllocator: Allocator + Allocator @@ -67,14 +65,14 @@ where #[inline] fn from_superset_unchecked(v: &OVector>) -> Self { - let coords = v.generic_slice((0, 0), (D::name(), Const::<1>)) / v[D::dim()].inlined_clone(); + let coords = v.generic_slice((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone(); Self { coords: crate::convert_unchecked(coords), } } } -impl From> for OVector> +impl From> for OVector> where D: DimNameAdd, DefaultAllocator: Allocator> + Allocator, @@ -85,7 +83,7 @@ where } } -impl From<[T; D]> for Point { +impl From<[T; D]> for Point { #[inline] fn from(coords: [T; D]) -> Self { Point { @@ -94,14 +92,14 @@ impl From<[T; D]> for Point { } } -impl From> for [T; D] { +impl From> for [T; D] { #[inline] fn from(p: Point) -> Self { p.coords.into() } } -impl From> for OPoint +impl From> for OPoint where DefaultAllocator: Allocator, { diff --git a/src/geometry/point_ops.rs b/src/geometry/point_ops.rs index 5b019a9d..72d91ff3 100644 --- a/src/geometry/point_ops.rs +++ b/src/geometry/point_ops.rs @@ -21,7 +21,7 @@ use crate::DefaultAllocator; * Indexing. * */ -impl Index for OPoint +impl Index for OPoint where DefaultAllocator: Allocator, { @@ -33,7 +33,7 @@ where } } -impl IndexMut for OPoint +impl IndexMut for OPoint where DefaultAllocator: Allocator, { diff --git a/src/geometry/point_simba.rs b/src/geometry/point_simba.rs index ad7433af..7355af0e 100644 --- a/src/geometry/point_simba.rs +++ b/src/geometry/point_simba.rs @@ -1,13 +1,10 @@ use simba::simd::SimdValue; -use crate::base::{OVector, Scalar}; +use crate::base::OVector; use crate::geometry::Point; -impl SimdValue for Point -where - T::Element: Scalar, -{ +impl SimdValue for Point { type Element = Point; type SimdBool = T::SimdBool; diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index e512a930..b6798c9f 100755 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -33,13 +33,13 @@ pub struct Quaternion { pub coords: Vector4, } -impl Hash for Quaternion { +impl Hash for Quaternion { fn hash(&self, state: &mut H) { self.coords.hash(state) } } -impl Eq for Quaternion {} +impl Eq for Quaternion {} impl PartialEq for Quaternion { #[inline] @@ -48,7 +48,7 @@ impl PartialEq for Quaternion { } } -impl Default for Quaternion { +impl Default for Quaternion { fn default() -> Self { Quaternion { coords: Vector4::zeros(), diff --git a/src/third_party/mint/mint_quaternion.rs b/src/third_party/mint/mint_quaternion.rs index f41815ce..49b99f04 100644 --- a/src/third_party/mint/mint_quaternion.rs +++ b/src/third_party/mint/mint_quaternion.rs @@ -1,6 +1,6 @@ use crate::{Quaternion, Scalar, SimdValue, UnitQuaternion}; -impl From> for Quaternion { +impl From> for Quaternion { fn from(q: mint::Quaternion) -> Self { Self::new(q.s, q.v.x, q.v.y, q.v.z) }