mutable_constant/
impls.rs1use crate::Mc;
2
3
4impl<T> std::fmt::Debug for Mc<T>
5where
6 T: std::fmt::Debug
7{
8 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9 unsafe { &*self.0 }.fmt(f)
10 }
11}
12
13impl<T> std::fmt::Display for Mc<T>
14where
15 T: std::fmt::Display
16{
17 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
18 unsafe { &*self.0 }.fmt(f)
19 }
20}
21
22impl<T> Clone for Mc<T>
23where
24 T: Clone
25{
26 fn clone(&self) -> Self {
27 Mc::new(unsafe { &*self.0 }.clone())
28 }
29}
30
31impl<T> std::ops::Deref for Mc<T> {
32 type Target = T;
33
34 fn deref(&self) -> &Self::Target {
35 unsafe { &*self.0 }
36 }
37}
38
39impl<T> std::ops::DerefMut for Mc<T> {
40 fn deref_mut(&mut self) -> &mut Self::Target {
41 unsafe { &mut *self.0 }
42 }
43}
44
45impl<T, R> std::ops::Add<R> for Mc<T>
46where
47 T: std::ops::Add<R> + Clone
48{
49 type Output = T::Output;
50
51 fn add(self, rhs: R) -> Self::Output {
52 unsafe { &*self.0 }.clone() + rhs
53 }
54}
55
56impl<T, R> std::ops::AddAssign<R> for Mc<T>
57where
58 T: std::ops::AddAssign<R>
59{
60 fn add_assign(&mut self, rhs: R) {
61 unsafe { &mut *self.0 }.add_assign(rhs);
62 }
63}
64
65impl<T, R> std::ops::Sub<R> for Mc<T>
66where
67 T: std::ops::Sub<R> + Clone
68{
69 type Output = T::Output;
70
71 fn sub(self, rhs: R) -> Self::Output {
72 unsafe { &*self.0 }.clone() - rhs
73 }
74}
75
76impl<T, R> std::ops::SubAssign<R> for Mc<T>
77where
78 T: std::ops::SubAssign<R>
79{
80 fn sub_assign(&mut self, rhs: R) {
81 unsafe { &mut *self.0 }.sub_assign(rhs);
82 }
83}
84
85impl<T, R> std::ops::Mul<R> for Mc<T>
86where
87 T: std::ops::Mul<R> + Clone
88{
89 type Output = T::Output;
90
91 fn mul(self, rhs: R) -> Self::Output {
92 unsafe { &*self.0 }.clone() * rhs
93 }
94}
95
96impl<T, R> std::ops::MulAssign<R> for Mc<T>
97where
98 T: std::ops::MulAssign<R>
99{
100 fn mul_assign(&mut self, rhs: R) {
101 unsafe { &mut *self.0 }.mul_assign(rhs);
102 }
103}
104
105impl<T, R> std::ops::Div<R> for Mc<T>
106where
107 T: std::ops::Div<R> + Clone
108{
109 type Output = T::Output;
110
111 fn div(self, rhs: R) -> Self::Output {
112 unsafe { &*self.0 }.clone() / rhs
113 }
114}
115
116impl<T, R> std::ops::DivAssign<R> for Mc<T>
117where
118 T: std::ops::DivAssign<R>
119{
120 fn div_assign(&mut self, rhs: R) {
121 unsafe { &mut *self.0 }.div_assign(rhs);
122 }
123}
124
125impl<T, R> std::ops::Rem<R> for Mc<T>
126where
127 T: std::ops::Rem<R> + Clone
128{
129 type Output = T::Output;
130
131 fn rem(self, rhs: R) -> Self::Output {
132 unsafe { &*self.0 }.clone() % rhs
133 }
134}
135
136impl<T, R> std::ops::RemAssign<R> for Mc<T>
137where
138 T: std::ops::RemAssign<R>
139{
140 fn rem_assign(&mut self, rhs: R) {
141 unsafe { &mut *self.0 }.rem_assign(rhs);
142 }
143}
144
145impl<T> std::ops::Neg for Mc<T>
146where
147 T: std::ops::Neg + Clone
148{
149 type Output = T::Output;
150
151 fn neg(self) -> Self::Output {
152 -unsafe { &*self.0 }.clone()
153 }
154}
155
156impl<T> std::ops::Not for Mc<T>
157where
158 T: std::ops::Not + Clone
159{
160 type Output = T::Output;
161
162 fn not(self) -> Self::Output {
163 !unsafe { &*self.0 }.clone()
164 }
165}
166
167impl<T, R> std::ops::BitAnd<R> for Mc<T>
168where
169 T: std::ops::BitAnd<R> + Clone
170{
171 type Output = T::Output;
172
173 fn bitand(self, rhs: R) -> Self::Output {
174 unsafe { &*self.0 }.clone() & rhs
175 }
176}
177
178impl<T, R> std::ops::BitAndAssign<R> for Mc<T>
179where
180 T: std::ops::BitAndAssign<R>
181{
182 fn bitand_assign(&mut self, rhs: R) {
183 unsafe { &mut *self.0 }.bitand_assign(rhs);
184 }
185}
186
187impl<T, R> std::ops::BitOr<R> for Mc<T>
188where
189 T: std::ops::BitOr<R> + Clone
190{
191 type Output = T::Output;
192
193 fn bitor(self, rhs: R) -> Self::Output {
194 unsafe { &*self.0 }.clone() | rhs
195 }
196}
197
198impl<T, R> std::ops::BitOrAssign<R> for Mc<T>
199where
200 T: std::ops::BitOrAssign<R>
201{
202 fn bitor_assign(&mut self, rhs: R) {
203 unsafe { &mut *self.0 }.bitor_assign(rhs);
204 }
205}
206
207impl<T, R> std::ops::BitXor<R> for Mc<T>
208where
209 T: std::ops::BitXor<R> + Clone
210{
211 type Output = T::Output;
212
213 fn bitxor(self, rhs: R) -> Self::Output {
214 unsafe { &*self.0 }.clone() ^ rhs
215 }
216}
217
218impl<T, R> std::ops::BitXorAssign<R> for Mc<T>
219where
220 T: std::ops::BitXorAssign<R>
221{
222 fn bitxor_assign(&mut self, rhs: R) {
223 unsafe { &mut *self.0 }.bitxor_assign(rhs);
224 }
225}
226
227impl<T> std::ops::Shl<usize> for Mc<T>
228where
229 T: std::ops::Shl<usize> + Clone
230{
231 type Output = T::Output;
232
233 fn shl(self, rhs: usize) -> Self::Output {
234 unsafe { &*self.0 }.clone() << rhs
235 }
236}
237
238impl<T> std::ops::ShlAssign<usize> for Mc<T>
239where
240 T: std::ops::ShlAssign<usize>
241{
242 fn shl_assign(&mut self, rhs: usize) {
243 unsafe { &mut *self.0 }.shl_assign(rhs);
244 }
245}
246
247impl<T> std::ops::Shr<usize> for Mc<T>
248where
249 T: std::ops::Shr<usize> + Clone
250{
251 type Output = T::Output;
252
253 fn shr(self, rhs: usize) -> Self::Output {
254 unsafe { &*self.0 }.clone() >> rhs
255 }
256}
257
258impl<T> std::ops::ShrAssign<usize> for Mc<T>
259where
260 T: std::ops::ShrAssign<usize>
261{
262 fn shr_assign(&mut self, rhs: usize) {
263 unsafe { &mut *self.0 }.shr_assign(rhs);
264 }
265}
266
267impl<T, R> PartialEq<R> for Mc<T>
268where
269 T: PartialEq<R> + Clone
270{
271 fn eq(&self, other: &R) -> bool {
272 unsafe { &*self.0 }.clone() == *other
273 }
274}
275
276impl<T, R> PartialOrd<R> for Mc<T>
277where
278 T: PartialOrd<R> + Clone
279{
280 fn partial_cmp(&self, other: &R) -> Option<std::cmp::Ordering> {
281 unsafe { &*self.0 }.clone().partial_cmp(other)
282 }
283}
284
285impl<T> Eq for Mc<T>
286where
287 T: Eq + Clone + PartialEq<Mc<T>>
288{}
289
290impl<T> Ord for Mc<T>
291where
292 T: Ord + Clone + PartialOrd<Mc<T>>
293{
294 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
295 unsafe { &*self.0 }.clone().cmp(unsafe { &*other.0 })
296 }
297}
298
299impl<T> std::hash::Hash for Mc<T>
300where
301 T: std::hash::Hash + Clone
302{
303 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
304 unsafe { &*self.0 }.clone().hash(state);
305 }
306}