Move the bytemuck impls to GenericArray and add a transitive impl for matrices.

This commit is contained in:
Crozet Sébastien 2021-02-25 14:10:34 +01:00
parent 1c0891bbbb
commit dc15261ec1
2 changed files with 26 additions and 9 deletions

View File

@ -394,6 +394,26 @@ where
} }
} }
#[cfg(feature = "bytemuck")]
unsafe impl<N: Scalar + bytemuck::Zeroable, R: DimName, C: DimName> bytemuck::Zeroable
for ArrayStorage<N, R, C>
where
R::Value: Mul<C::Value>,
Prod<R::Value, C::Value>: ArrayLength<N>,
Self: Copy,
{
}
#[cfg(feature = "bytemuck")]
unsafe impl<N: Scalar + bytemuck::Pod, R: DimName, C: DimName> bytemuck::Pod
for ArrayStorage<N, R, C>
where
R::Value: Mul<C::Value>,
Prod<R::Value, C::Value>: ArrayLength<N>,
Self: Copy,
{
}
#[cfg(feature = "abomonation-serialize")] #[cfg(feature = "abomonation-serialize")]
impl<N, R, C> Abomonation for ArrayStorage<N, R, C> impl<N, R, C> Abomonation for ArrayStorage<N, R, C>
where where

View File

@ -280,21 +280,18 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> matrixcompare_core::DenseAc
} }
#[cfg(feature = "bytemuck")] #[cfg(feature = "bytemuck")]
unsafe impl<N: Scalar + Copy, R: crate::base::dimension::DimName, C: crate::base::dimension::DimName> unsafe impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> bytemuck::Zeroable
bytemuck::Zeroable for Matrix<N, R, C, crate::base::ArrayStorage<N, R, C>> for Matrix<N, R, C, S>
where where
R::Value: core::ops::Mul<C::Value>, S: bytemuck::Zeroable,
<R::Value as core::ops::Mul<C::Value>>::Output: generic_array::ArrayLength<N>,
{ {
} }
#[cfg(feature = "bytemuck")] #[cfg(feature = "bytemuck")]
unsafe impl<N: Scalar + Copy, R: crate::base::dimension::DimName, C: crate::base::dimension::DimName> unsafe impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> bytemuck::Pod for Matrix<N, R, C, S>
bytemuck::Pod for Matrix<N, R, C, crate::base::ArrayStorage<N, R, C>>
where where
R::Value: core::ops::Mul<C::Value>, S: bytemuck::Pod,
<R::Value as core::ops::Mul<C::Value>>::Output: generic_array::ArrayLength<N>, Self: Copy,
<<R::Value as core::ops::Mul<<C as crate::base::dimension::DimName>::Value>>::Output as generic_array::ArrayLength<N>>::ArrayType: Copy
{ {
} }