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