rust_extra/arrays/
Array128.rs1#[repr(C, packed)]
6pub struct Array128<T>(pub [T; 128]);
7
8impl<T> Array<T> for Array128<T>
9{
10 const Size: usize = 128;
11 const Mask: usize = 128 - 1;
12
13 #[inline(always)]
14 unsafe fn get_unchecked(&self, index: usize) -> &T
15 {
16 self.0.get_unchecked(index)
17 }
18
19 #[inline(always)]
20 unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T
21 {
22 self.0.get_unchecked_mut(index)
23 }
24
25 #[inline(always)]
26 fn as_ptr(&self) -> *const T
27 {
28 self.0.as_ptr()
29 }
30
31 #[inline(always)]
32 fn as_mut_ptr(&mut self) -> *mut T
33 {
34 self.0.as_mut_ptr()
35 }
36}
37
38impl<T: Copy> Copy for Array128<T>
39{
40}
41
42impl<T: Copy> Clone for Array128<T>
43{
44 #[inline(always)]
45 fn clone(&self) -> Self
46 {
47 Array128(self.0)
48 }
49}
50
51impl<T: Debug> Debug for Array128<T>
52{
53 #[inline(always)]
54 fn fmt(&self, formatter: &mut Formatter) -> Result
55 {
56 self.0[..].fmt(formatter)
57 }
58}
59
60impl<T: PartialEq> PartialEq for Array128<T>
61{
62 #[inline(always)]
63 fn eq(&self, other: &Array128<T>) -> bool
64 {
65 self.0[..].eq(&other.0[..])
66 }
67}
68
69impl<T: Eq> Eq for Array128<T>
70{
71}
72
73impl<T: PartialOrd> PartialOrd for Array128<T>
74{
75 #[inline(always)]
76 fn partial_cmp(&self, other: &Array128<T>) -> Option<Ordering>
77 {
78 PartialOrd::partial_cmp(&&self.0[..], &&other.0[..])
79 }
80
81 #[inline(always)]
82 fn lt(&self, other: &Array128<T>) -> bool
83 {
84 PartialOrd::lt(&&self.0[..], &&other.0[..])
85 }
86
87 #[inline(always)]
88 fn le(&self, other: &Array128<T>) -> bool
89 {
90 PartialOrd::le(&&self.0[..], &&other.0[..])
91 }
92
93 #[inline(always)]
94 fn ge(&self, other: &Array128<T>) -> bool
95 {
96 PartialOrd::ge(&&self.0[..], &&other.0[..])
97 }
98
99 #[inline(always)]
100 fn gt(&self, other: &Array128<T>) -> bool
101 {
102 PartialOrd::gt(&&self.0[..], &&other.0[..])
103 }
104}
105
106impl<T: Ord> Ord for Array128<T>
107{
108 #[inline(always)]
109 fn cmp(&self, other: &Array128<T>) -> Ordering
110 {
111 Ord::cmp(&&self.0[..], &&other.0[..])
112 }
113}
114
115impl<T: Hash> Hash for Array128<T>
116{
117 #[inline(always)]
118 fn hash<H: Hasher>(&self, state: &mut H)
119 {
120 Hash::hash(&self.0[..], state)
121 }
122}
123
124impl<'a, T> IntoIterator for &'a Array128<T>
125{
126 type Item = &'a T;
127 type IntoIter = Iter<'a, T>;
128
129 #[inline(always)]
130 fn into_iter(self) -> Iter<'a, T>
131 {
132 self.0.iter()
133 }
134}
135
136impl<'a, T> IntoIterator for &'a mut Array128<T>
137{
138 type Item = &'a mut T;
139 type IntoIter = IterMut<'a, T>;
140
141 #[inline(always)]
142 fn into_iter(self) -> IterMut<'a, T>
143 {
144 self.0.iter_mut()
145 }
146}
147
148impl<T> AsRef<[T]> for Array128<T>
149{
150 #[inline(always)]
151 fn as_ref(&self) -> &[T]
152 {
153 &self.0[..]
154 }
155}
156
157impl<T> AsMut<[T]> for Array128<T>
158{
159 #[inline(always)]
160 fn as_mut(&mut self) -> &mut [T]
161 {
162 &mut self.0[..]
163 }
164}