Debian Codegraph @

debian/missing-sources/glam-0.16.0/src/features/impl_bytemuck.rs

raw
1 use crate::{
2 DMat2, DMat3, DMat4, DQuat, DVec2, DVec3, DVec4, IVec2, IVec3, IVec4, Mat2, Mat3, Mat4, Quat,
3 UVec2, UVec3, UVec4, Vec2, Vec3, Vec4,
4 };
5 use bytemuck::{Pod, Zeroable};
6
7 unsafe impl Pod for Mat2 {}
8 unsafe impl Zeroable for Mat2 {}
9 unsafe impl Pod for Mat3 {}
10 unsafe impl Zeroable for Mat3 {}
11 unsafe impl Pod for Mat4 {}
12 unsafe impl Zeroable for Mat4 {}
13
14 unsafe impl Pod for Quat {}
15 unsafe impl Zeroable for Quat {}
16
17 unsafe impl Pod for Vec2 {}
18 unsafe impl Zeroable for Vec2 {}
19 unsafe impl Pod for Vec3 {}
20 unsafe impl Zeroable for Vec3 {}
21 unsafe impl Pod for Vec4 {}
22 unsafe impl Zeroable for Vec4 {}
23
24 unsafe impl Pod for DMat2 {}
25 unsafe impl Zeroable for DMat2 {}
26 unsafe impl Pod for DMat3 {}
27 unsafe impl Zeroable for DMat3 {}
28 unsafe impl Pod for DMat4 {}
29 unsafe impl Zeroable for DMat4 {}
30
31 unsafe impl Pod for DQuat {}
32 unsafe impl Zeroable for DQuat {}
33
34 unsafe impl Pod for DVec2 {}
35 unsafe impl Zeroable for DVec2 {}
36 unsafe impl Pod for DVec3 {}
37 unsafe impl Zeroable for DVec3 {}
38 unsafe impl Pod for DVec4 {}
39 unsafe impl Zeroable for DVec4 {}
40
41 unsafe impl Pod for IVec2 {}
42 unsafe impl Zeroable for IVec2 {}
43 unsafe impl Pod for IVec3 {}
44 unsafe impl Zeroable for IVec3 {}
45 unsafe impl Pod for IVec4 {}
46 unsafe impl Zeroable for IVec4 {}
47
48 unsafe impl Pod for UVec2 {}
49 unsafe impl Zeroable for UVec2 {}
50 unsafe impl Pod for UVec3 {}
51 unsafe impl Zeroable for UVec3 {}
52 unsafe impl Pod for UVec4 {}
53 unsafe impl Zeroable for UVec4 {}
54
55 #[cfg(test)]
56 mod test {
57 use crate::{
58 DMat2, DMat3, DMat4, DQuat, DVec2, DVec3, DVec4, IVec2, IVec3, IVec4, Mat2, Mat3, Mat4,
59 Quat, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4,
60 };
61 use core::mem;
62
63 macro_rules! test_t {
64 ($name:ident, $t:ty) => {
65 #[test]
66 fn $name() {
67 let t = <$t>::default();
68 let b = bytemuck::bytes_of(&t);
69 assert_eq!(t.as_ref().as_ptr() as usize, b.as_ptr() as usize);
70 assert_eq!(b.len(), mem::size_of_val(&t));
71 }
72 };
73 }
74
75 test_t!(mat2, Mat2);
76 test_t!(mat3, Mat3);
77 test_t!(mat4, Mat4);
78 test_t!(quat, Quat);
79 test_t!(vec2, Vec2);
80 test_t!(vec3, Vec3);
81 test_t!(vec4, Vec4);
82
83 test_t!(dmat2, DMat2);
84 test_t!(dmat3, DMat3);
85 test_t!(dmat4, DMat4);
86 test_t!(dquat, DQuat);
87 test_t!(dvec2, DVec2);
88 test_t!(dvec3, DVec3);
89 test_t!(dvec4, DVec4);
90
91 test_t!(ivec2, IVec2);
92 test_t!(ivec3, IVec3);
93 test_t!(ivec4, IVec4);
94
95 test_t!(uvec2, UVec2);
96 test_t!(uvec3, UVec3);
97 test_t!(uvec4, UVec4);
98 }