wider_primitives/stable_ops/
u512.rs1use core::cmp;
2use core::ops;
3use core::str;
4use crate::u256;
5use crate::u384;
6use crate::u512;
7
8impl cmp::PartialOrd for u512 {
9 fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
10 Some(self.cmp(other))
11 }
12}
13
14impl cmp::Ord for u512 {
15 fn cmp(&self, other: &Self) -> cmp::Ordering {
16 self.inner.compare_unsigned(&other.inner)
17 }
18}
19
20impl ops::Add for &u512 {
21 type Output = u512;
22
23 fn add(self, rhs: Self) -> Self::Output {
24 (*self).add(*rhs)
25 }
26}
27
28impl ops::Add<u512> for &u512 {
29 type Output = u512;
30
31 fn add(self, rhs: u512) -> Self::Output {
32 (*self).add(rhs)
33 }
34}
35
36impl ops::Add<&u512> for u512 {
37 type Output = Self;
38
39 fn add(self, rhs: &u512) -> Self::Output {
40 self.add(*rhs)
41 }
42}
43
44impl ops::Add for u512 {
45 type Output = Self;
46
47 fn add(self, rhs: Self) -> Self::Output {
48 self.add(rhs)
49 }
50}
51
52impl ops::AddAssign for u512 {
53 fn add_assign(&mut self, rhs: Self) {
54 *self = *self + rhs;
55 }
56}
57
58impl ops::AddAssign<&u512> for u512 {
59 fn add_assign(&mut self, rhs: &u512) {
60 *self = *self + *rhs;
61 }
62}
63
64impl ops::Sub for &u512 {
65 type Output = u512;
66
67 fn sub(self, rhs: Self) -> Self::Output {
68 (*self).sub(*rhs)
69 }
70}
71
72impl ops::Sub<u512> for &u512 {
73 type Output = u512;
74
75 fn sub(self, rhs: u512) -> Self::Output {
76 (*self).sub(rhs)
77 }
78}
79
80impl ops::Sub<&u512> for u512 {
81 type Output = Self;
82
83 fn sub(self, rhs: &u512) -> Self::Output {
84 self.sub(*rhs)
85 }
86}
87
88impl ops::Sub for u512 {
89 type Output = Self;
90
91 fn sub(self, rhs: Self) -> Self::Output {
92 self.sub(rhs)
93 }
94}
95
96impl ops::SubAssign for u512 {
97 fn sub_assign(&mut self, rhs: Self) {
98 *self = *self - rhs;
99 }
100}
101
102impl ops::SubAssign<&u512> for u512 {
103 fn sub_assign(&mut self, rhs: &u512) {
104 *self = *self - *rhs;
105 }
106}
107
108impl ops::Mul<&u64> for &u512 {
109 type Output = u512;
110
111 fn mul(self, rhs: &u64) -> Self::Output {
112 (*self).short_mul(*rhs)
113 }
114}
115
116impl ops::Mul<u64> for &u512 {
117 type Output = u512;
118
119 fn mul(self, rhs: u64) -> Self::Output {
120 (*self).short_mul(rhs)
121 }
122}
123
124impl ops::Mul<&u64> for u512 {
125 type Output = u512;
126
127 fn mul(self, rhs: &u64) -> Self::Output {
128 self.short_mul(*rhs)
129 }
130}
131
132impl ops::Mul<u64> for u512 {
133 type Output = u512;
134
135 fn mul(self, rhs: u64) -> Self::Output {
136 self.short_mul(rhs)
137 }
138}
139
140impl ops::Mul for &u512 {
141 type Output = u512;
142
143 fn mul(self, rhs: Self) -> Self::Output {
144 (*self).mul(*rhs)
145 }
146}
147
148impl ops::Mul<u512> for &u512 {
149 type Output = u512;
150
151 fn mul(self, rhs: u512) -> Self::Output {
152 (*self).mul(rhs)
153 }
154}
155
156impl ops::Mul<&u512> for u512 {
157 type Output = Self;
158
159 fn mul(self, rhs: &u512) -> Self::Output {
160 self.mul(*rhs)
161 }
162}
163
164impl ops::Mul for u512 {
165 type Output = Self;
166
167 fn mul(self, rhs: Self) -> Self::Output {
168 self.mul(rhs)
169 }
170}
171
172impl ops::MulAssign for u512 {
173 fn mul_assign(&mut self, rhs: Self) {
174 *self = *self * rhs;
175 }
176}
177
178impl ops::MulAssign<&u512> for u512 {
179 fn mul_assign(&mut self, rhs: &u512) {
180 *self = *self * *rhs;
181 }
182}
183
184impl ops::MulAssign<u64> for u512 {
185 fn mul_assign(&mut self, rhs: u64) {
186 *self = *self * rhs;
187 }
188}
189
190impl ops::MulAssign<&u64> for u512 {
191 fn mul_assign(&mut self, rhs: &u64) {
192 *self = *self * *rhs;
193 }
194}
195
196impl ops::Div<&u64> for &u512 {
197 type Output = u512;
198
199 fn div(self, rhs: &u64) -> Self::Output {
200 (*self).short_div(*rhs)
201 }
202}
203
204impl ops::Div<u64> for &u512 {
205 type Output = u512;
206
207 fn div(self, rhs: u64) -> Self::Output {
208 (*self).short_div(rhs)
209 }
210}
211
212impl ops::Div<&u64> for u512 {
213 type Output = u512;
214
215 fn div(self, rhs: &u64) -> Self::Output {
216 self.short_div(*rhs)
217 }
218}
219
220impl ops::Div<u64> for u512 {
221 type Output = u512;
222
223 fn div(self, rhs: u64) -> Self::Output {
224 self.short_div(rhs)
225 }
226}
227
228impl ops::Div for &u512 {
229 type Output = u512;
230
231 fn div(self, rhs: Self) -> Self::Output {
232 (*self).div(*rhs)
233 }
234}
235
236impl ops::Div<u512> for &u512 {
237 type Output = u512;
238
239 fn div(self, rhs: u512) -> Self::Output {
240 (*self).div(rhs)
241 }
242}
243
244impl ops::Div<&u512> for u512 {
245 type Output = Self;
246
247 fn div(self, rhs: &u512) -> Self::Output {
248 self.div(*rhs)
249 }
250}
251
252impl ops::Div for u512 {
253 type Output = Self;
254
255 fn div(self, rhs: Self) -> Self::Output {
256 self.div(rhs)
257 }
258}
259
260impl ops::DivAssign for u512 {
261 fn div_assign(&mut self, rhs: Self) {
262 *self = *self / rhs;
263 }
264}
265
266impl ops::DivAssign<&u512> for u512 {
267 fn div_assign(&mut self, rhs: &u512) {
268 *self = *self / *rhs;
269 }
270}
271
272impl ops::DivAssign<u64> for u512 {
273 fn div_assign(&mut self, rhs: u64) {
274 *self = *self / rhs;
275 }
276}
277
278impl ops::DivAssign<&u64> for u512 {
279 fn div_assign(&mut self, rhs: &u64) {
280 *self = *self / *rhs;
281 }
282}
283
284impl ops::Rem<&u64> for &u512 {
285 type Output = u64;
286
287 fn rem(self, rhs: &u64) -> Self::Output {
288 (*self).short_rem(*rhs)
289 }
290}
291
292impl ops::Rem<u64> for &u512 {
293 type Output = u64;
294
295 fn rem(self, rhs: u64) -> Self::Output {
296 (*self).short_rem(rhs)
297 }
298}
299
300impl ops::Rem<&u64> for u512 {
301 type Output = u64;
302
303 fn rem(self, rhs: &u64) -> Self::Output {
304 self.short_rem(*rhs)
305 }
306}
307
308impl ops::Rem<u64> for u512 {
309 type Output = u64;
310
311 fn rem(self, rhs: u64) -> Self::Output {
312 self.short_rem(rhs)
313 }
314}
315
316impl ops::Rem for &u512 {
317 type Output = u512;
318
319 fn rem(self, rhs: Self) -> Self::Output {
320 (*self).rem(*rhs)
321 }
322}
323
324impl ops::Rem<u512> for &u512 {
325 type Output = u512;
326
327 fn rem(self, rhs: u512) -> Self::Output {
328 (*self).rem(rhs)
329 }
330}
331
332impl ops::Rem<&u512> for u512 {
333 type Output = Self;
334
335 fn rem(self, rhs: &u512) -> Self::Output {
336 self.rem(*rhs)
337 }
338}
339
340impl ops::Rem for u512 {
341 type Output = Self;
342
343 fn rem(self, rhs: Self) -> Self::Output {
344 self.rem(rhs)
345 }
346}
347
348impl ops::RemAssign for u512 {
349 fn rem_assign(&mut self, rhs: Self) {
350 *self = *self % rhs;
351 }
352}
353
354impl ops::RemAssign<&u512> for u512 {
355 fn rem_assign(&mut self, rhs: &u512) {
356 *self = *self % *rhs;
357 }
358}
359
360impl ops::RemAssign<u64> for u512 {
361 fn rem_assign(&mut self, rhs: u64) {
362 *self = Self::from_u64(*self % rhs);
363 }
364}
365
366impl ops::RemAssign<&u64> for u512 {
367 fn rem_assign(&mut self, rhs: &u64) {
368 *self = Self::from_u64(*self % *rhs);
369 }
370}
371
372impl ops::Not for u512 {
373 type Output = Self;
374
375 fn not(self) -> Self::Output {
376 self.not()
377 }
378}
379
380impl ops::Not for &u512 {
381 type Output = u512;
382
383 fn not(self) -> Self::Output {
384 (*self).not()
385 }
386}
387
388impl ops::BitAnd for &u512 {
389 type Output = u512;
390
391 fn bitand(self, rhs: Self) -> Self::Output {
392 (*self).bitand(*rhs)
393 }
394}
395
396impl ops::BitAnd<u512> for &u512 {
397 type Output = u512;
398
399 fn bitand(self, rhs: u512) -> Self::Output {
400 (*self).bitand(rhs)
401 }
402}
403
404impl ops::BitAnd<&u512> for u512 {
405 type Output = Self;
406
407 fn bitand(self, rhs: &u512) -> Self::Output {
408 self.bitand(*rhs)
409 }
410}
411
412impl ops::BitAnd for u512 {
413 type Output = Self;
414
415 fn bitand(self, rhs: Self) -> Self::Output {
416 self.bitand(rhs)
417 }
418}
419
420impl ops::BitAndAssign for u512 {
421 fn bitand_assign(&mut self, rhs: Self) {
422 *self = *self & rhs;
423 }
424}
425
426impl ops::BitAndAssign<&u512> for u512 {
427 fn bitand_assign(&mut self, rhs: &Self) {
428 *self = *self & *rhs;
429 }
430}
431
432impl ops::BitOr for &u512 {
433 type Output = u512;
434
435 fn bitor(self, rhs: Self) -> Self::Output {
436 (*self).bitor(*rhs)
437 }
438}
439
440impl ops::BitOr<u512> for &u512 {
441 type Output = u512;
442
443 fn bitor(self, rhs: u512) -> Self::Output {
444 (*self).bitor(rhs)
445 }
446}
447
448impl ops::BitOr<&u512> for u512 {
449 type Output = Self;
450
451 fn bitor(self, rhs: &u512) -> Self::Output {
452 self.bitor(*rhs)
453 }
454}
455
456impl ops::BitOr for u512 {
457 type Output = Self;
458
459 fn bitor(self, rhs: Self) -> Self::Output {
460 self.bitor(rhs)
461 }
462}
463
464impl ops::BitOrAssign for u512 {
465 fn bitor_assign(&mut self, rhs: Self) {
466 *self = *self | rhs;
467 }
468}
469
470impl ops::BitOrAssign<&u512> for u512 {
471 fn bitor_assign(&mut self, rhs: &Self) {
472 *self = *self | *rhs;
473 }
474}
475
476impl ops::BitXor for &u512 {
477 type Output = u512;
478
479 fn bitxor(self, rhs: Self) -> Self::Output {
480 (*self).bitxor(*rhs)
481 }
482}
483
484impl ops::BitXor<u512> for &u512 {
485 type Output = u512;
486
487 fn bitxor(self, rhs: u512) -> Self::Output {
488 (*self).bitxor(rhs)
489 }
490}
491
492impl ops::BitXor<&u512> for u512 {
493 type Output = Self;
494
495 fn bitxor(self, rhs: &u512) -> Self::Output {
496 self.bitxor(*rhs)
497 }
498}
499
500impl ops::BitXor for u512 {
501 type Output = Self;
502
503 fn bitxor(self, rhs: Self) -> Self::Output {
504 self.bitxor(rhs)
505 }
506}
507
508impl ops::BitXorAssign for u512 {
509 fn bitxor_assign(&mut self, rhs: Self) {
510 *self = *self ^ rhs;
511 }
512}
513
514impl ops::BitXorAssign<&u512> for u512 {
515 fn bitxor_assign(&mut self, rhs: &Self) {
516 *self = *self ^ *rhs;
517 }
518}
519
520impl From<u8> for u512 {
521 fn from(n: u8) -> Self {
522 Self::from_u8(n)
523 }
524}
525
526impl From<u16> for u512 {
527 fn from(n: u16) -> Self {
528 Self::from_u16(n)
529 }
530}
531
532impl From<u32> for u512 {
533 fn from(n: u32) -> Self {
534 Self::from_u32(n)
535 }
536}
537
538impl From<u64> for u512 {
539 fn from(n: u64) -> Self {
540 Self::from_u64(n)
541 }
542}
543
544impl From<u128> for u512 {
545 fn from(n: u128) -> Self {
546 Self::from_u128(n)
547 }
548}
549
550impl From<u256> for u512 {
551 fn from(n: u256) -> Self {
552 Self::from_u256(n)
553 }
554}
555
556impl From<u384> for u512 {
557 fn from(n: u384) -> Self {
558 Self::from_u384(n)
559 }
560}
561
562impl str::FromStr for u512 {
563 type Err = crate::ParseIntError;
564
565 fn from_str(src: &str) -> Result<Self, Self::Err> {
566 Self::from_str(src)
567 }
568}
569
570impl ops::Shl<&u32> for u512 {
571 type Output = Self;
572
573 fn shl(self, rhs: &u32) -> Self::Output {
574 self.shl(*rhs)
575 }
576}
577
578impl ops::Shl<u32> for u512 {
579 type Output = Self;
580
581 fn shl(self, rhs: u32) -> Self::Output {
582 self.shl(rhs)
583 }
584}
585
586impl ops::ShlAssign<&u32> for u512 {
587 fn shl_assign(&mut self, rhs: &u32) {
588 *self = *self << rhs;
589 }
590}
591
592impl ops::ShlAssign<u32> for u512 {
593 fn shl_assign(&mut self, rhs: u32) {
594 *self = *self << rhs;
595 }
596}
597
598impl ops::Shr<&u32> for u512 {
599 type Output = Self;
600
601 fn shr(self, rhs: &u32) -> Self::Output {
602 self.shr(*rhs)
603 }
604}
605
606impl ops::Shr<u32> for u512 {
607 type Output = Self;
608
609 fn shr(self, rhs: u32) -> Self::Output {
610 self.shr(rhs)
611 }
612}
613
614impl ops::ShrAssign<&u32> for u512 {
615 fn shr_assign(&mut self, rhs: &u32) {
616 *self = *self >> rhs;
617 }
618}
619
620impl ops::ShrAssign<u32> for u512 {
621 fn shr_assign(&mut self, rhs: u32) {
622 *self = *self >> rhs;
623 }
624}