From dc15261ec15da0797dad8d3687b247db2c26ca4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Thu, 25 Feb 2021 14:10:34 +0100 Subject: [PATCH] Move the bytemuck impls to GenericArray and add a transitive impl for matrices. --- src/base/array_storage.rs | 20 ++++++++++++++++++++ src/base/matrix.rs | 15 ++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index 4fdd3e73..e067cb49 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -394,6 +394,26 @@ where } } +#[cfg(feature = "bytemuck")] +unsafe impl bytemuck::Zeroable + for ArrayStorage +where + R::Value: Mul, + Prod: ArrayLength, + Self: Copy, +{ +} + +#[cfg(feature = "bytemuck")] +unsafe impl bytemuck::Pod + for ArrayStorage +where + R::Value: Mul, + Prod: ArrayLength, + Self: Copy, +{ +} + #[cfg(feature = "abomonation-serialize")] impl Abomonation for ArrayStorage where diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 73001536..eb525b14 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -280,21 +280,18 @@ impl> matrixcompare_core::DenseAc } #[cfg(feature = "bytemuck")] -unsafe impl - bytemuck::Zeroable for Matrix> +unsafe impl> bytemuck::Zeroable + for Matrix where - R::Value: core::ops::Mul, - >::Output: generic_array::ArrayLength, + S: bytemuck::Zeroable, { } #[cfg(feature = "bytemuck")] -unsafe impl - bytemuck::Pod for Matrix> +unsafe impl> bytemuck::Pod for Matrix where - R::Value: core::ops::Mul, - >::Output: generic_array::ArrayLength, - <::Value>>::Output as generic_array::ArrayLength>::ArrayType: Copy + S: bytemuck::Pod, + Self: Copy, { }