1pub trait Vec2<T> {
2 fn from_slice(slice: &[T; 2]) -> Self
3 where
4 Self: Sized;
5 fn as_slice(&self) -> &[T; 2];
6 fn as_ptr(&self) -> *const T;
7}
8
9impl<T> Vec2<T> for [T; 2]
10where
11 T: Copy,
12 Self: Sized,
13{
14 fn from_slice(slice: &[T; 2]) -> [T; 2] {
15 *slice
16 }
17
18 fn as_slice(&self) -> &[T; 2] {
19 self
20 }
21
22 fn as_ptr(&self) -> *const T {
23 self as *const T
24 }
25}
26
27pub trait Vec3<T>
28where
29 Self: Sized,
30{
31 fn from_slice(slice: &[T; 3]) -> Self;
32 fn as_slice(&self) -> &[T; 3];
33 fn as_ptr(&self) -> *const T;
34}
35
36impl<T> Vec3<T> for [T; 3]
37where
38 T: Copy,
39{
40 fn from_slice(slice: &[T; 3]) -> Self {
41 *slice
42 }
43
44 fn as_slice(&self) -> &[T; 3] {
45 self
46 }
47
48 fn as_ptr(&self) -> *const T {
49 self as *const T
50 }
51}
52
53pub trait Vec4<T>
54where
55 Self: Sized,
56{
57 fn from_slice(slice: &[T; 4]) -> Self;
58 fn as_slice(&self) -> &[T; 4];
59 fn as_ptr(&self) -> *const T;
60}
61
62impl<T> Vec4<T> for [T; 4]
63where
64 T: Copy,
65{
66 fn from_slice(slice: &[T; 4]) -> Self {
67 *slice
68 }
69
70 fn as_slice(&self) -> &[T; 4] {
71 self
72 }
73
74 fn as_ptr(&self) -> *const T {
75 self as *const T
76 }
77}