diff --git a/Cargo.toml b/Cargo.toml index 7d5a9db9..3fd9ae81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,6 @@ compare = [ "matrixcompare-core" ] libm = [ "simba/libm" ] libm-force = [ "simba/libm_force" ] - [dependencies] typenum = "1.12" generic-array = "0.14" @@ -55,6 +54,7 @@ mint = { version = "0.5", optional = true } quickcheck = { version = "0.9", optional = true } pest = { version = "2", optional = true } pest_derive = { version = "2", optional = true } +bytemuck = { version = "1.5", optional = true } matrixcompare-core = { version = "0.1", optional = true } [dev-dependencies] diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 8035d2f8..73001536 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -279,6 +279,25 @@ 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>> +where + R::Value: core::ops::Mul<C::Value>, + <R::Value as core::ops::Mul<C::Value>>::Output: generic_array::ArrayLength<N>, +{ +} + +#[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>> +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 +{ +} + impl<N: Scalar, R: Dim, C: Dim, S> Matrix<N, R, C, S> { /// Creates a new matrix with the given data without statically checking that the matrix /// dimension matches the storage dimension.