Merge pull request #831 from iMplode-nZ/dev
Added bytemuck implementations for static storages.
This commit is contained in:
commit
69e2ad6a44
|
@ -40,7 +40,6 @@ proptest-support = [ "proptest" ]
|
||||||
# This feature is only used for tests, and enables tests that require more time to run
|
# This feature is only used for tests, and enables tests that require more time to run
|
||||||
slow-tests = []
|
slow-tests = []
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
typenum = "1.12"
|
typenum = "1.12"
|
||||||
generic-array = "0.14"
|
generic-array = "0.14"
|
||||||
|
@ -59,6 +58,7 @@ mint = { version = "0.5", optional = true }
|
||||||
quickcheck = { version = "0.9", optional = true }
|
quickcheck = { version = "0.9", optional = true }
|
||||||
pest = { version = "2", optional = true }
|
pest = { version = "2", optional = true }
|
||||||
pest_derive = { version = "2", optional = true }
|
pest_derive = { version = "2", optional = true }
|
||||||
|
bytemuck = { version = "1.5", optional = true }
|
||||||
matrixcompare-core = { version = "0.1", optional = true }
|
matrixcompare-core = { version = "0.1", optional = true }
|
||||||
proptest = { version = "0.10", optional = true, default-features = false, features = ["std"] }
|
proptest = { version = "0.10", optional = true, default-features = false, features = ["std"] }
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -279,6 +279,22 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> matrixcompare_core::DenseAc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> bytemuck::Zeroable
|
||||||
|
for Matrix<N, R, C, S>
|
||||||
|
where
|
||||||
|
S: bytemuck::Zeroable,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> bytemuck::Pod for Matrix<N, R, C, S>
|
||||||
|
where
|
||||||
|
S: bytemuck::Pod,
|
||||||
|
Self: Copy,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
impl<N: Scalar, R: Dim, C: Dim, S> Matrix<N, R, C, S> {
|
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
|
/// Creates a new matrix with the given data without statically checking that the matrix
|
||||||
/// dimension matches the storage dimension.
|
/// dimension matches the storage dimension.
|
||||||
|
|
|
@ -30,6 +30,12 @@ pub struct Unit<T> {
|
||||||
pub(crate) value: T,
|
pub(crate) value: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Zeroable for Unit<T> where T: bytemuck::Zeroable {}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Pod for Unit<T> where T: bytemuck::Pod {}
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize")]
|
#[cfg(feature = "serde-serialize")]
|
||||||
impl<T: Serialize> Serialize for Unit<T> {
|
impl<T: Serialize> Serialize for Unit<T> {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
|
|
@ -65,6 +65,24 @@ where
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<N: Scalar, D: DimName> bytemuck::Zeroable for Point<N, D>
|
||||||
|
where
|
||||||
|
VectorN<N, D>: bytemuck::Zeroable,
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<N: Scalar, D: DimName> bytemuck::Pod for Point<N, D>
|
||||||
|
where
|
||||||
|
N: Copy,
|
||||||
|
VectorN<N, D>: bytemuck::Pod,
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
|
<DefaultAllocator as Allocator<N, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize")]
|
#[cfg(feature = "serde-serialize")]
|
||||||
impl<N: Scalar, D: DimName> Serialize for Point<N, D>
|
impl<N: Scalar, D: DimName> Serialize for Point<N, D>
|
||||||
where
|
where
|
||||||
|
|
|
@ -40,6 +40,17 @@ impl<N: Scalar + Zero> Default for Quaternion<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<N: Scalar> bytemuck::Zeroable for Quaternion<N> where Vector4<N>: bytemuck::Zeroable {}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<N: Scalar> bytemuck::Pod for Quaternion<N>
|
||||||
|
where
|
||||||
|
Vector4<N>: bytemuck::Pod,
|
||||||
|
N: Copy,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
impl<N: Scalar> Abomonation for Quaternion<N>
|
impl<N: Scalar> Abomonation for Quaternion<N>
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in New Issue