1use crate::{BVec2, I16Vec2, I64Vec2, I8Vec2, IVec2, U16Vec2, U64Vec2, U8Vec2, USizeVec3, UVec2};
4
5use core::fmt;
6use core::iter::{Product, Sum};
7use core::{f32, ops::*};
8
9#[cfg(feature = "zerocopy")]
10use zerocopy_derive::*;
11
12#[inline(always)]
14#[must_use]
15pub const fn usizevec2(x: usize, y: usize) -> USizeVec2 {
16 USizeVec2::new(x, y)
17}
18
19#[derive(Clone, Copy, PartialEq, Eq, Hash)]
21#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
22#[cfg_attr(
23 feature = "zerocopy",
24 derive(FromBytes, Immutable, IntoBytes, KnownLayout)
25)]
26#[cfg_attr(feature = "cuda", repr(align(16)))]
27#[repr(C)]
28#[cfg_attr(target_arch = "spirv", rust_gpu::vector::v1)]
29pub struct USizeVec2 {
30 pub x: usize,
31 pub y: usize,
32}
33
34impl USizeVec2 {
35 pub const ZERO: Self = Self::splat(0);
37
38 pub const ONE: Self = Self::splat(1);
40
41 pub const MIN: Self = Self::splat(usize::MIN);
43
44 pub const MAX: Self = Self::splat(usize::MAX);
46
47 pub const X: Self = Self::new(1, 0);
49
50 pub const Y: Self = Self::new(0, 1);
52
53 pub const AXES: [Self; 2] = [Self::X, Self::Y];
55
56 #[inline(always)]
58 #[must_use]
59 pub const fn new(x: usize, y: usize) -> Self {
60 Self { x, y }
61 }
62
63 #[inline]
65 #[must_use]
66 pub const fn splat(v: usize) -> Self {
67 Self { x: v, y: v }
68 }
69
70 #[inline]
72 #[must_use]
73 pub fn map<F>(self, f: F) -> Self
74 where
75 F: Fn(usize) -> usize,
76 {
77 Self::new(f(self.x), f(self.y))
78 }
79
80 #[inline]
86 #[must_use]
87 pub fn select(mask: BVec2, if_true: Self, if_false: Self) -> Self {
88 Self {
89 x: if mask.test(0) { if_true.x } else { if_false.x },
90 y: if mask.test(1) { if_true.y } else { if_false.y },
91 }
92 }
93
94 #[inline]
96 #[must_use]
97 pub const fn from_array(a: [usize; 2]) -> Self {
98 Self::new(a[0], a[1])
99 }
100
101 #[inline]
103 #[must_use]
104 pub const fn to_array(&self) -> [usize; 2] {
105 [self.x, self.y]
106 }
107
108 #[inline]
114 #[must_use]
115 pub const fn from_slice(slice: &[usize]) -> Self {
116 assert!(slice.len() >= 2);
117 Self::new(slice[0], slice[1])
118 }
119
120 #[inline]
126 pub fn write_to_slice(self, slice: &mut [usize]) {
127 slice[..2].copy_from_slice(&self.to_array());
128 }
129
130 #[inline]
132 #[must_use]
133 pub const fn extend(self, z: usize) -> USizeVec3 {
134 USizeVec3::new(self.x, self.y, z)
135 }
136
137 #[inline]
139 #[must_use]
140 pub fn with_x(mut self, x: usize) -> Self {
141 self.x = x;
142 self
143 }
144
145 #[inline]
147 #[must_use]
148 pub fn with_y(mut self, y: usize) -> Self {
149 self.y = y;
150 self
151 }
152
153 #[inline]
155 #[must_use]
156 pub fn dot(self, rhs: Self) -> usize {
157 (self.x * rhs.x) + (self.y * rhs.y)
158 }
159
160 #[inline]
162 #[must_use]
163 pub fn dot_into_vec(self, rhs: Self) -> Self {
164 Self::splat(self.dot(rhs))
165 }
166
167 #[inline]
171 #[must_use]
172 pub fn min(self, rhs: Self) -> Self {
173 Self {
174 x: if self.x < rhs.x { self.x } else { rhs.x },
175 y: if self.y < rhs.y { self.y } else { rhs.y },
176 }
177 }
178
179 #[inline]
183 #[must_use]
184 pub fn max(self, rhs: Self) -> Self {
185 Self {
186 x: if self.x > rhs.x { self.x } else { rhs.x },
187 y: if self.y > rhs.y { self.y } else { rhs.y },
188 }
189 }
190
191 #[inline]
199 #[must_use]
200 pub fn clamp(self, min: Self, max: Self) -> Self {
201 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
202 self.max(min).min(max)
203 }
204
205 #[inline]
209 #[must_use]
210 pub fn min_element(self) -> usize {
211 let min = |a, b| if a < b { a } else { b };
212 min(self.x, self.y)
213 }
214
215 #[inline]
219 #[must_use]
220 pub fn max_element(self) -> usize {
221 let max = |a, b| if a > b { a } else { b };
222 max(self.x, self.y)
223 }
224
225 #[doc(alias = "argmin")]
227 #[inline]
228 #[must_use]
229 pub fn min_position(self) -> usize {
230 if self.x <= self.y {
231 0
232 } else {
233 1
234 }
235 }
236
237 #[doc(alias = "argmax")]
239 #[inline]
240 #[must_use]
241 pub fn max_position(self) -> usize {
242 if self.x >= self.y {
243 0
244 } else {
245 1
246 }
247 }
248
249 #[inline]
253 #[must_use]
254 pub fn element_sum(self) -> usize {
255 self.x + self.y
256 }
257
258 #[inline]
262 #[must_use]
263 pub fn element_product(self) -> usize {
264 self.x * self.y
265 }
266
267 #[inline]
273 #[must_use]
274 pub fn cmpeq(self, rhs: Self) -> BVec2 {
275 BVec2::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y))
276 }
277
278 #[inline]
284 #[must_use]
285 pub fn cmpne(self, rhs: Self) -> BVec2 {
286 BVec2::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y))
287 }
288
289 #[inline]
295 #[must_use]
296 pub fn cmpge(self, rhs: Self) -> BVec2 {
297 BVec2::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y))
298 }
299
300 #[inline]
306 #[must_use]
307 pub fn cmpgt(self, rhs: Self) -> BVec2 {
308 BVec2::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y))
309 }
310
311 #[inline]
317 #[must_use]
318 pub fn cmple(self, rhs: Self) -> BVec2 {
319 BVec2::new(self.x.le(&rhs.x), self.y.le(&rhs.y))
320 }
321
322 #[inline]
328 #[must_use]
329 pub fn cmplt(self, rhs: Self) -> BVec2 {
330 BVec2::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y))
331 }
332
333 #[doc(alias = "magnitude2")]
335 #[inline]
336 #[must_use]
337 pub fn length_squared(self) -> usize {
338 self.dot(self)
339 }
340
341 #[inline]
350 #[must_use]
351 pub fn manhattan_distance(self, rhs: Self) -> usize {
352 self.x.abs_diff(rhs.x) + self.y.abs_diff(rhs.y)
353 }
354
355 #[inline]
361 #[must_use]
362 pub fn checked_manhattan_distance(self, rhs: Self) -> Option<usize> {
363 let d = self.x.abs_diff(rhs.x);
364 d.checked_add(self.y.abs_diff(rhs.y))
365 }
366
367 #[inline]
371 #[must_use]
372 pub fn chebyshev_distance(self, rhs: Self) -> usize {
373 [self.x.abs_diff(rhs.x), self.y.abs_diff(rhs.y)]
375 .into_iter()
376 .max()
377 .unwrap()
378 }
379
380 #[inline]
382 #[must_use]
383 pub fn as_vec2(&self) -> crate::Vec2 {
384 crate::Vec2::new(self.x as f32, self.y as f32)
385 }
386
387 #[inline]
389 #[must_use]
390 pub fn as_dvec2(&self) -> crate::DVec2 {
391 crate::DVec2::new(self.x as f64, self.y as f64)
392 }
393
394 #[inline]
396 #[must_use]
397 pub fn as_i8vec2(&self) -> crate::I8Vec2 {
398 crate::I8Vec2::new(self.x as i8, self.y as i8)
399 }
400
401 #[inline]
403 #[must_use]
404 pub fn as_u8vec2(&self) -> crate::U8Vec2 {
405 crate::U8Vec2::new(self.x as u8, self.y as u8)
406 }
407
408 #[inline]
410 #[must_use]
411 pub fn as_i16vec2(&self) -> crate::I16Vec2 {
412 crate::I16Vec2::new(self.x as i16, self.y as i16)
413 }
414
415 #[inline]
417 #[must_use]
418 pub fn as_u16vec2(&self) -> crate::U16Vec2 {
419 crate::U16Vec2::new(self.x as u16, self.y as u16)
420 }
421
422 #[inline]
424 #[must_use]
425 pub fn as_ivec2(&self) -> crate::IVec2 {
426 crate::IVec2::new(self.x as i32, self.y as i32)
427 }
428
429 #[inline]
431 #[must_use]
432 pub fn as_uvec2(&self) -> crate::UVec2 {
433 crate::UVec2::new(self.x as u32, self.y as u32)
434 }
435
436 #[inline]
438 #[must_use]
439 pub fn as_i64vec2(&self) -> crate::I64Vec2 {
440 crate::I64Vec2::new(self.x as i64, self.y as i64)
441 }
442
443 #[inline]
445 #[must_use]
446 pub fn as_u64vec2(&self) -> crate::U64Vec2 {
447 crate::U64Vec2::new(self.x as u64, self.y as u64)
448 }
449
450 #[inline]
454 #[must_use]
455 pub const fn checked_add(self, rhs: Self) -> Option<Self> {
456 let x = match self.x.checked_add(rhs.x) {
457 Some(v) => v,
458 None => return None,
459 };
460 let y = match self.y.checked_add(rhs.y) {
461 Some(v) => v,
462 None => return None,
463 };
464
465 Some(Self { x, y })
466 }
467
468 #[inline]
472 #[must_use]
473 pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
474 let x = match self.x.checked_sub(rhs.x) {
475 Some(v) => v,
476 None => return None,
477 };
478 let y = match self.y.checked_sub(rhs.y) {
479 Some(v) => v,
480 None => return None,
481 };
482
483 Some(Self { x, y })
484 }
485
486 #[inline]
490 #[must_use]
491 pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
492 let x = match self.x.checked_mul(rhs.x) {
493 Some(v) => v,
494 None => return None,
495 };
496 let y = match self.y.checked_mul(rhs.y) {
497 Some(v) => v,
498 None => return None,
499 };
500
501 Some(Self { x, y })
502 }
503
504 #[inline]
508 #[must_use]
509 pub const fn checked_div(self, rhs: Self) -> Option<Self> {
510 let x = match self.x.checked_div(rhs.x) {
511 Some(v) => v,
512 None => return None,
513 };
514 let y = match self.y.checked_div(rhs.y) {
515 Some(v) => v,
516 None => return None,
517 };
518
519 Some(Self { x, y })
520 }
521
522 #[inline]
526 #[must_use]
527 pub const fn wrapping_add(self, rhs: Self) -> Self {
528 Self {
529 x: self.x.wrapping_add(rhs.x),
530 y: self.y.wrapping_add(rhs.y),
531 }
532 }
533
534 #[inline]
538 #[must_use]
539 pub const fn wrapping_sub(self, rhs: Self) -> Self {
540 Self {
541 x: self.x.wrapping_sub(rhs.x),
542 y: self.y.wrapping_sub(rhs.y),
543 }
544 }
545
546 #[inline]
550 #[must_use]
551 pub const fn wrapping_mul(self, rhs: Self) -> Self {
552 Self {
553 x: self.x.wrapping_mul(rhs.x),
554 y: self.y.wrapping_mul(rhs.y),
555 }
556 }
557
558 #[inline]
562 #[must_use]
563 pub const fn wrapping_div(self, rhs: Self) -> Self {
564 Self {
565 x: self.x.wrapping_div(rhs.x),
566 y: self.y.wrapping_div(rhs.y),
567 }
568 }
569
570 #[inline]
574 #[must_use]
575 pub const fn saturating_add(self, rhs: Self) -> Self {
576 Self {
577 x: self.x.saturating_add(rhs.x),
578 y: self.y.saturating_add(rhs.y),
579 }
580 }
581
582 #[inline]
586 #[must_use]
587 pub const fn saturating_sub(self, rhs: Self) -> Self {
588 Self {
589 x: self.x.saturating_sub(rhs.x),
590 y: self.y.saturating_sub(rhs.y),
591 }
592 }
593
594 #[inline]
598 #[must_use]
599 pub const fn saturating_mul(self, rhs: Self) -> Self {
600 Self {
601 x: self.x.saturating_mul(rhs.x),
602 y: self.y.saturating_mul(rhs.y),
603 }
604 }
605
606 #[inline]
610 #[must_use]
611 pub const fn saturating_div(self, rhs: Self) -> Self {
612 Self {
613 x: self.x.saturating_div(rhs.x),
614 y: self.y.saturating_div(rhs.y),
615 }
616 }
617}
618
619impl Default for USizeVec2 {
620 #[inline(always)]
621 fn default() -> Self {
622 Self::ZERO
623 }
624}
625
626impl Div for USizeVec2 {
627 type Output = Self;
628 #[inline]
629 fn div(self, rhs: Self) -> Self {
630 Self {
631 x: self.x.div(rhs.x),
632 y: self.y.div(rhs.y),
633 }
634 }
635}
636
637impl Div<&Self> for USizeVec2 {
638 type Output = Self;
639 #[inline]
640 fn div(self, rhs: &Self) -> Self {
641 self.div(*rhs)
642 }
643}
644
645impl Div<&USizeVec2> for &USizeVec2 {
646 type Output = USizeVec2;
647 #[inline]
648 fn div(self, rhs: &USizeVec2) -> USizeVec2 {
649 (*self).div(*rhs)
650 }
651}
652
653impl Div<USizeVec2> for &USizeVec2 {
654 type Output = USizeVec2;
655 #[inline]
656 fn div(self, rhs: USizeVec2) -> USizeVec2 {
657 (*self).div(rhs)
658 }
659}
660
661impl DivAssign for USizeVec2 {
662 #[inline]
663 fn div_assign(&mut self, rhs: Self) {
664 self.x.div_assign(rhs.x);
665 self.y.div_assign(rhs.y);
666 }
667}
668
669impl DivAssign<&Self> for USizeVec2 {
670 #[inline]
671 fn div_assign(&mut self, rhs: &Self) {
672 self.div_assign(*rhs);
673 }
674}
675
676impl Div<usize> for USizeVec2 {
677 type Output = Self;
678 #[inline]
679 fn div(self, rhs: usize) -> Self {
680 Self {
681 x: self.x.div(rhs),
682 y: self.y.div(rhs),
683 }
684 }
685}
686
687impl Div<&usize> for USizeVec2 {
688 type Output = Self;
689 #[inline]
690 fn div(self, rhs: &usize) -> Self {
691 self.div(*rhs)
692 }
693}
694
695impl Div<&usize> for &USizeVec2 {
696 type Output = USizeVec2;
697 #[inline]
698 fn div(self, rhs: &usize) -> USizeVec2 {
699 (*self).div(*rhs)
700 }
701}
702
703impl Div<usize> for &USizeVec2 {
704 type Output = USizeVec2;
705 #[inline]
706 fn div(self, rhs: usize) -> USizeVec2 {
707 (*self).div(rhs)
708 }
709}
710
711impl DivAssign<usize> for USizeVec2 {
712 #[inline]
713 fn div_assign(&mut self, rhs: usize) {
714 self.x.div_assign(rhs);
715 self.y.div_assign(rhs);
716 }
717}
718
719impl DivAssign<&usize> for USizeVec2 {
720 #[inline]
721 fn div_assign(&mut self, rhs: &usize) {
722 self.div_assign(*rhs);
723 }
724}
725
726impl Div<USizeVec2> for usize {
727 type Output = USizeVec2;
728 #[inline]
729 fn div(self, rhs: USizeVec2) -> USizeVec2 {
730 USizeVec2 {
731 x: self.div(rhs.x),
732 y: self.div(rhs.y),
733 }
734 }
735}
736
737impl Div<&USizeVec2> for usize {
738 type Output = USizeVec2;
739 #[inline]
740 fn div(self, rhs: &USizeVec2) -> USizeVec2 {
741 self.div(*rhs)
742 }
743}
744
745impl Div<&USizeVec2> for &usize {
746 type Output = USizeVec2;
747 #[inline]
748 fn div(self, rhs: &USizeVec2) -> USizeVec2 {
749 (*self).div(*rhs)
750 }
751}
752
753impl Div<USizeVec2> for &usize {
754 type Output = USizeVec2;
755 #[inline]
756 fn div(self, rhs: USizeVec2) -> USizeVec2 {
757 (*self).div(rhs)
758 }
759}
760
761impl Mul for USizeVec2 {
762 type Output = Self;
763 #[inline]
764 fn mul(self, rhs: Self) -> Self {
765 Self {
766 x: self.x.mul(rhs.x),
767 y: self.y.mul(rhs.y),
768 }
769 }
770}
771
772impl Mul<&Self> for USizeVec2 {
773 type Output = Self;
774 #[inline]
775 fn mul(self, rhs: &Self) -> Self {
776 self.mul(*rhs)
777 }
778}
779
780impl Mul<&USizeVec2> for &USizeVec2 {
781 type Output = USizeVec2;
782 #[inline]
783 fn mul(self, rhs: &USizeVec2) -> USizeVec2 {
784 (*self).mul(*rhs)
785 }
786}
787
788impl Mul<USizeVec2> for &USizeVec2 {
789 type Output = USizeVec2;
790 #[inline]
791 fn mul(self, rhs: USizeVec2) -> USizeVec2 {
792 (*self).mul(rhs)
793 }
794}
795
796impl MulAssign for USizeVec2 {
797 #[inline]
798 fn mul_assign(&mut self, rhs: Self) {
799 self.x.mul_assign(rhs.x);
800 self.y.mul_assign(rhs.y);
801 }
802}
803
804impl MulAssign<&Self> for USizeVec2 {
805 #[inline]
806 fn mul_assign(&mut self, rhs: &Self) {
807 self.mul_assign(*rhs);
808 }
809}
810
811impl Mul<usize> for USizeVec2 {
812 type Output = Self;
813 #[inline]
814 fn mul(self, rhs: usize) -> Self {
815 Self {
816 x: self.x.mul(rhs),
817 y: self.y.mul(rhs),
818 }
819 }
820}
821
822impl Mul<&usize> for USizeVec2 {
823 type Output = Self;
824 #[inline]
825 fn mul(self, rhs: &usize) -> Self {
826 self.mul(*rhs)
827 }
828}
829
830impl Mul<&usize> for &USizeVec2 {
831 type Output = USizeVec2;
832 #[inline]
833 fn mul(self, rhs: &usize) -> USizeVec2 {
834 (*self).mul(*rhs)
835 }
836}
837
838impl Mul<usize> for &USizeVec2 {
839 type Output = USizeVec2;
840 #[inline]
841 fn mul(self, rhs: usize) -> USizeVec2 {
842 (*self).mul(rhs)
843 }
844}
845
846impl MulAssign<usize> for USizeVec2 {
847 #[inline]
848 fn mul_assign(&mut self, rhs: usize) {
849 self.x.mul_assign(rhs);
850 self.y.mul_assign(rhs);
851 }
852}
853
854impl MulAssign<&usize> for USizeVec2 {
855 #[inline]
856 fn mul_assign(&mut self, rhs: &usize) {
857 self.mul_assign(*rhs);
858 }
859}
860
861impl Mul<USizeVec2> for usize {
862 type Output = USizeVec2;
863 #[inline]
864 fn mul(self, rhs: USizeVec2) -> USizeVec2 {
865 USizeVec2 {
866 x: self.mul(rhs.x),
867 y: self.mul(rhs.y),
868 }
869 }
870}
871
872impl Mul<&USizeVec2> for usize {
873 type Output = USizeVec2;
874 #[inline]
875 fn mul(self, rhs: &USizeVec2) -> USizeVec2 {
876 self.mul(*rhs)
877 }
878}
879
880impl Mul<&USizeVec2> for &usize {
881 type Output = USizeVec2;
882 #[inline]
883 fn mul(self, rhs: &USizeVec2) -> USizeVec2 {
884 (*self).mul(*rhs)
885 }
886}
887
888impl Mul<USizeVec2> for &usize {
889 type Output = USizeVec2;
890 #[inline]
891 fn mul(self, rhs: USizeVec2) -> USizeVec2 {
892 (*self).mul(rhs)
893 }
894}
895
896impl Add for USizeVec2 {
897 type Output = Self;
898 #[inline]
899 fn add(self, rhs: Self) -> Self {
900 Self {
901 x: self.x.add(rhs.x),
902 y: self.y.add(rhs.y),
903 }
904 }
905}
906
907impl Add<&Self> for USizeVec2 {
908 type Output = Self;
909 #[inline]
910 fn add(self, rhs: &Self) -> Self {
911 self.add(*rhs)
912 }
913}
914
915impl Add<&USizeVec2> for &USizeVec2 {
916 type Output = USizeVec2;
917 #[inline]
918 fn add(self, rhs: &USizeVec2) -> USizeVec2 {
919 (*self).add(*rhs)
920 }
921}
922
923impl Add<USizeVec2> for &USizeVec2 {
924 type Output = USizeVec2;
925 #[inline]
926 fn add(self, rhs: USizeVec2) -> USizeVec2 {
927 (*self).add(rhs)
928 }
929}
930
931impl AddAssign for USizeVec2 {
932 #[inline]
933 fn add_assign(&mut self, rhs: Self) {
934 self.x.add_assign(rhs.x);
935 self.y.add_assign(rhs.y);
936 }
937}
938
939impl AddAssign<&Self> for USizeVec2 {
940 #[inline]
941 fn add_assign(&mut self, rhs: &Self) {
942 self.add_assign(*rhs);
943 }
944}
945
946impl Add<usize> for USizeVec2 {
947 type Output = Self;
948 #[inline]
949 fn add(self, rhs: usize) -> Self {
950 Self {
951 x: self.x.add(rhs),
952 y: self.y.add(rhs),
953 }
954 }
955}
956
957impl Add<&usize> for USizeVec2 {
958 type Output = Self;
959 #[inline]
960 fn add(self, rhs: &usize) -> Self {
961 self.add(*rhs)
962 }
963}
964
965impl Add<&usize> for &USizeVec2 {
966 type Output = USizeVec2;
967 #[inline]
968 fn add(self, rhs: &usize) -> USizeVec2 {
969 (*self).add(*rhs)
970 }
971}
972
973impl Add<usize> for &USizeVec2 {
974 type Output = USizeVec2;
975 #[inline]
976 fn add(self, rhs: usize) -> USizeVec2 {
977 (*self).add(rhs)
978 }
979}
980
981impl AddAssign<usize> for USizeVec2 {
982 #[inline]
983 fn add_assign(&mut self, rhs: usize) {
984 self.x.add_assign(rhs);
985 self.y.add_assign(rhs);
986 }
987}
988
989impl AddAssign<&usize> for USizeVec2 {
990 #[inline]
991 fn add_assign(&mut self, rhs: &usize) {
992 self.add_assign(*rhs);
993 }
994}
995
996impl Add<USizeVec2> for usize {
997 type Output = USizeVec2;
998 #[inline]
999 fn add(self, rhs: USizeVec2) -> USizeVec2 {
1000 USizeVec2 {
1001 x: self.add(rhs.x),
1002 y: self.add(rhs.y),
1003 }
1004 }
1005}
1006
1007impl Add<&USizeVec2> for usize {
1008 type Output = USizeVec2;
1009 #[inline]
1010 fn add(self, rhs: &USizeVec2) -> USizeVec2 {
1011 self.add(*rhs)
1012 }
1013}
1014
1015impl Add<&USizeVec2> for &usize {
1016 type Output = USizeVec2;
1017 #[inline]
1018 fn add(self, rhs: &USizeVec2) -> USizeVec2 {
1019 (*self).add(*rhs)
1020 }
1021}
1022
1023impl Add<USizeVec2> for &usize {
1024 type Output = USizeVec2;
1025 #[inline]
1026 fn add(self, rhs: USizeVec2) -> USizeVec2 {
1027 (*self).add(rhs)
1028 }
1029}
1030
1031impl Sub for USizeVec2 {
1032 type Output = Self;
1033 #[inline]
1034 fn sub(self, rhs: Self) -> Self {
1035 Self {
1036 x: self.x.sub(rhs.x),
1037 y: self.y.sub(rhs.y),
1038 }
1039 }
1040}
1041
1042impl Sub<&Self> for USizeVec2 {
1043 type Output = Self;
1044 #[inline]
1045 fn sub(self, rhs: &Self) -> Self {
1046 self.sub(*rhs)
1047 }
1048}
1049
1050impl Sub<&USizeVec2> for &USizeVec2 {
1051 type Output = USizeVec2;
1052 #[inline]
1053 fn sub(self, rhs: &USizeVec2) -> USizeVec2 {
1054 (*self).sub(*rhs)
1055 }
1056}
1057
1058impl Sub<USizeVec2> for &USizeVec2 {
1059 type Output = USizeVec2;
1060 #[inline]
1061 fn sub(self, rhs: USizeVec2) -> USizeVec2 {
1062 (*self).sub(rhs)
1063 }
1064}
1065
1066impl SubAssign for USizeVec2 {
1067 #[inline]
1068 fn sub_assign(&mut self, rhs: Self) {
1069 self.x.sub_assign(rhs.x);
1070 self.y.sub_assign(rhs.y);
1071 }
1072}
1073
1074impl SubAssign<&Self> for USizeVec2 {
1075 #[inline]
1076 fn sub_assign(&mut self, rhs: &Self) {
1077 self.sub_assign(*rhs);
1078 }
1079}
1080
1081impl Sub<usize> for USizeVec2 {
1082 type Output = Self;
1083 #[inline]
1084 fn sub(self, rhs: usize) -> Self {
1085 Self {
1086 x: self.x.sub(rhs),
1087 y: self.y.sub(rhs),
1088 }
1089 }
1090}
1091
1092impl Sub<&usize> for USizeVec2 {
1093 type Output = Self;
1094 #[inline]
1095 fn sub(self, rhs: &usize) -> Self {
1096 self.sub(*rhs)
1097 }
1098}
1099
1100impl Sub<&usize> for &USizeVec2 {
1101 type Output = USizeVec2;
1102 #[inline]
1103 fn sub(self, rhs: &usize) -> USizeVec2 {
1104 (*self).sub(*rhs)
1105 }
1106}
1107
1108impl Sub<usize> for &USizeVec2 {
1109 type Output = USizeVec2;
1110 #[inline]
1111 fn sub(self, rhs: usize) -> USizeVec2 {
1112 (*self).sub(rhs)
1113 }
1114}
1115
1116impl SubAssign<usize> for USizeVec2 {
1117 #[inline]
1118 fn sub_assign(&mut self, rhs: usize) {
1119 self.x.sub_assign(rhs);
1120 self.y.sub_assign(rhs);
1121 }
1122}
1123
1124impl SubAssign<&usize> for USizeVec2 {
1125 #[inline]
1126 fn sub_assign(&mut self, rhs: &usize) {
1127 self.sub_assign(*rhs);
1128 }
1129}
1130
1131impl Sub<USizeVec2> for usize {
1132 type Output = USizeVec2;
1133 #[inline]
1134 fn sub(self, rhs: USizeVec2) -> USizeVec2 {
1135 USizeVec2 {
1136 x: self.sub(rhs.x),
1137 y: self.sub(rhs.y),
1138 }
1139 }
1140}
1141
1142impl Sub<&USizeVec2> for usize {
1143 type Output = USizeVec2;
1144 #[inline]
1145 fn sub(self, rhs: &USizeVec2) -> USizeVec2 {
1146 self.sub(*rhs)
1147 }
1148}
1149
1150impl Sub<&USizeVec2> for &usize {
1151 type Output = USizeVec2;
1152 #[inline]
1153 fn sub(self, rhs: &USizeVec2) -> USizeVec2 {
1154 (*self).sub(*rhs)
1155 }
1156}
1157
1158impl Sub<USizeVec2> for &usize {
1159 type Output = USizeVec2;
1160 #[inline]
1161 fn sub(self, rhs: USizeVec2) -> USizeVec2 {
1162 (*self).sub(rhs)
1163 }
1164}
1165
1166impl Rem for USizeVec2 {
1167 type Output = Self;
1168 #[inline]
1169 fn rem(self, rhs: Self) -> Self {
1170 Self {
1171 x: self.x.rem(rhs.x),
1172 y: self.y.rem(rhs.y),
1173 }
1174 }
1175}
1176
1177impl Rem<&Self> for USizeVec2 {
1178 type Output = Self;
1179 #[inline]
1180 fn rem(self, rhs: &Self) -> Self {
1181 self.rem(*rhs)
1182 }
1183}
1184
1185impl Rem<&USizeVec2> for &USizeVec2 {
1186 type Output = USizeVec2;
1187 #[inline]
1188 fn rem(self, rhs: &USizeVec2) -> USizeVec2 {
1189 (*self).rem(*rhs)
1190 }
1191}
1192
1193impl Rem<USizeVec2> for &USizeVec2 {
1194 type Output = USizeVec2;
1195 #[inline]
1196 fn rem(self, rhs: USizeVec2) -> USizeVec2 {
1197 (*self).rem(rhs)
1198 }
1199}
1200
1201impl RemAssign for USizeVec2 {
1202 #[inline]
1203 fn rem_assign(&mut self, rhs: Self) {
1204 self.x.rem_assign(rhs.x);
1205 self.y.rem_assign(rhs.y);
1206 }
1207}
1208
1209impl RemAssign<&Self> for USizeVec2 {
1210 #[inline]
1211 fn rem_assign(&mut self, rhs: &Self) {
1212 self.rem_assign(*rhs);
1213 }
1214}
1215
1216impl Rem<usize> for USizeVec2 {
1217 type Output = Self;
1218 #[inline]
1219 fn rem(self, rhs: usize) -> Self {
1220 Self {
1221 x: self.x.rem(rhs),
1222 y: self.y.rem(rhs),
1223 }
1224 }
1225}
1226
1227impl Rem<&usize> for USizeVec2 {
1228 type Output = Self;
1229 #[inline]
1230 fn rem(self, rhs: &usize) -> Self {
1231 self.rem(*rhs)
1232 }
1233}
1234
1235impl Rem<&usize> for &USizeVec2 {
1236 type Output = USizeVec2;
1237 #[inline]
1238 fn rem(self, rhs: &usize) -> USizeVec2 {
1239 (*self).rem(*rhs)
1240 }
1241}
1242
1243impl Rem<usize> for &USizeVec2 {
1244 type Output = USizeVec2;
1245 #[inline]
1246 fn rem(self, rhs: usize) -> USizeVec2 {
1247 (*self).rem(rhs)
1248 }
1249}
1250
1251impl RemAssign<usize> for USizeVec2 {
1252 #[inline]
1253 fn rem_assign(&mut self, rhs: usize) {
1254 self.x.rem_assign(rhs);
1255 self.y.rem_assign(rhs);
1256 }
1257}
1258
1259impl RemAssign<&usize> for USizeVec2 {
1260 #[inline]
1261 fn rem_assign(&mut self, rhs: &usize) {
1262 self.rem_assign(*rhs);
1263 }
1264}
1265
1266impl Rem<USizeVec2> for usize {
1267 type Output = USizeVec2;
1268 #[inline]
1269 fn rem(self, rhs: USizeVec2) -> USizeVec2 {
1270 USizeVec2 {
1271 x: self.rem(rhs.x),
1272 y: self.rem(rhs.y),
1273 }
1274 }
1275}
1276
1277impl Rem<&USizeVec2> for usize {
1278 type Output = USizeVec2;
1279 #[inline]
1280 fn rem(self, rhs: &USizeVec2) -> USizeVec2 {
1281 self.rem(*rhs)
1282 }
1283}
1284
1285impl Rem<&USizeVec2> for &usize {
1286 type Output = USizeVec2;
1287 #[inline]
1288 fn rem(self, rhs: &USizeVec2) -> USizeVec2 {
1289 (*self).rem(*rhs)
1290 }
1291}
1292
1293impl Rem<USizeVec2> for &usize {
1294 type Output = USizeVec2;
1295 #[inline]
1296 fn rem(self, rhs: USizeVec2) -> USizeVec2 {
1297 (*self).rem(rhs)
1298 }
1299}
1300
1301impl AsRef<[usize; 2]> for USizeVec2 {
1302 #[inline]
1303 fn as_ref(&self) -> &[usize; 2] {
1304 unsafe { &*(self as *const Self as *const [usize; 2]) }
1305 }
1306}
1307
1308impl AsMut<[usize; 2]> for USizeVec2 {
1309 #[inline]
1310 fn as_mut(&mut self) -> &mut [usize; 2] {
1311 unsafe { &mut *(self as *mut Self as *mut [usize; 2]) }
1312 }
1313}
1314
1315impl Sum for USizeVec2 {
1316 #[inline]
1317 fn sum<I>(iter: I) -> Self
1318 where
1319 I: Iterator<Item = Self>,
1320 {
1321 iter.fold(Self::ZERO, Self::add)
1322 }
1323}
1324
1325impl<'a> Sum<&'a Self> for USizeVec2 {
1326 #[inline]
1327 fn sum<I>(iter: I) -> Self
1328 where
1329 I: Iterator<Item = &'a Self>,
1330 {
1331 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1332 }
1333}
1334
1335impl Product for USizeVec2 {
1336 #[inline]
1337 fn product<I>(iter: I) -> Self
1338 where
1339 I: Iterator<Item = Self>,
1340 {
1341 iter.fold(Self::ONE, Self::mul)
1342 }
1343}
1344
1345impl<'a> Product<&'a Self> for USizeVec2 {
1346 #[inline]
1347 fn product<I>(iter: I) -> Self
1348 where
1349 I: Iterator<Item = &'a Self>,
1350 {
1351 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1352 }
1353}
1354
1355impl Not for USizeVec2 {
1356 type Output = Self;
1357 #[inline]
1358 fn not(self) -> Self {
1359 Self {
1360 x: self.x.not(),
1361 y: self.y.not(),
1362 }
1363 }
1364}
1365
1366impl Not for &USizeVec2 {
1367 type Output = USizeVec2;
1368 #[inline]
1369 fn not(self) -> USizeVec2 {
1370 (*self).not()
1371 }
1372}
1373
1374impl BitAnd for USizeVec2 {
1375 type Output = Self;
1376 #[inline]
1377 fn bitand(self, rhs: Self) -> Self::Output {
1378 Self {
1379 x: self.x.bitand(rhs.x),
1380 y: self.y.bitand(rhs.y),
1381 }
1382 }
1383}
1384
1385impl BitAnd<&Self> for USizeVec2 {
1386 type Output = Self;
1387 #[inline]
1388 fn bitand(self, rhs: &Self) -> Self {
1389 self.bitand(*rhs)
1390 }
1391}
1392
1393impl BitAnd<&USizeVec2> for &USizeVec2 {
1394 type Output = USizeVec2;
1395 #[inline]
1396 fn bitand(self, rhs: &USizeVec2) -> USizeVec2 {
1397 (*self).bitand(*rhs)
1398 }
1399}
1400
1401impl BitAnd<USizeVec2> for &USizeVec2 {
1402 type Output = USizeVec2;
1403 #[inline]
1404 fn bitand(self, rhs: USizeVec2) -> USizeVec2 {
1405 (*self).bitand(rhs)
1406 }
1407}
1408
1409impl BitAndAssign for USizeVec2 {
1410 #[inline]
1411 fn bitand_assign(&mut self, rhs: Self) {
1412 *self = self.bitand(rhs);
1413 }
1414}
1415
1416impl BitAndAssign<&Self> for USizeVec2 {
1417 #[inline]
1418 fn bitand_assign(&mut self, rhs: &Self) {
1419 self.bitand_assign(*rhs);
1420 }
1421}
1422
1423impl BitOr for USizeVec2 {
1424 type Output = Self;
1425 #[inline]
1426 fn bitor(self, rhs: Self) -> Self::Output {
1427 Self {
1428 x: self.x.bitor(rhs.x),
1429 y: self.y.bitor(rhs.y),
1430 }
1431 }
1432}
1433
1434impl BitOr<&Self> for USizeVec2 {
1435 type Output = Self;
1436 #[inline]
1437 fn bitor(self, rhs: &Self) -> Self {
1438 self.bitor(*rhs)
1439 }
1440}
1441
1442impl BitOr<&USizeVec2> for &USizeVec2 {
1443 type Output = USizeVec2;
1444 #[inline]
1445 fn bitor(self, rhs: &USizeVec2) -> USizeVec2 {
1446 (*self).bitor(*rhs)
1447 }
1448}
1449
1450impl BitOr<USizeVec2> for &USizeVec2 {
1451 type Output = USizeVec2;
1452 #[inline]
1453 fn bitor(self, rhs: USizeVec2) -> USizeVec2 {
1454 (*self).bitor(rhs)
1455 }
1456}
1457
1458impl BitOrAssign for USizeVec2 {
1459 #[inline]
1460 fn bitor_assign(&mut self, rhs: Self) {
1461 *self = self.bitor(rhs);
1462 }
1463}
1464
1465impl BitOrAssign<&Self> for USizeVec2 {
1466 #[inline]
1467 fn bitor_assign(&mut self, rhs: &Self) {
1468 self.bitor_assign(*rhs);
1469 }
1470}
1471
1472impl BitXor for USizeVec2 {
1473 type Output = Self;
1474 #[inline]
1475 fn bitxor(self, rhs: Self) -> Self::Output {
1476 Self {
1477 x: self.x.bitxor(rhs.x),
1478 y: self.y.bitxor(rhs.y),
1479 }
1480 }
1481}
1482
1483impl BitXor<&Self> for USizeVec2 {
1484 type Output = Self;
1485 #[inline]
1486 fn bitxor(self, rhs: &Self) -> Self {
1487 self.bitxor(*rhs)
1488 }
1489}
1490
1491impl BitXor<&USizeVec2> for &USizeVec2 {
1492 type Output = USizeVec2;
1493 #[inline]
1494 fn bitxor(self, rhs: &USizeVec2) -> USizeVec2 {
1495 (*self).bitxor(*rhs)
1496 }
1497}
1498
1499impl BitXor<USizeVec2> for &USizeVec2 {
1500 type Output = USizeVec2;
1501 #[inline]
1502 fn bitxor(self, rhs: USizeVec2) -> USizeVec2 {
1503 (*self).bitxor(rhs)
1504 }
1505}
1506
1507impl BitXorAssign for USizeVec2 {
1508 #[inline]
1509 fn bitxor_assign(&mut self, rhs: Self) {
1510 *self = self.bitxor(rhs);
1511 }
1512}
1513
1514impl BitXorAssign<&Self> for USizeVec2 {
1515 #[inline]
1516 fn bitxor_assign(&mut self, rhs: &Self) {
1517 self.bitxor_assign(*rhs);
1518 }
1519}
1520
1521impl BitAnd<usize> for USizeVec2 {
1522 type Output = Self;
1523 #[inline]
1524 fn bitand(self, rhs: usize) -> Self::Output {
1525 Self {
1526 x: self.x.bitand(rhs),
1527 y: self.y.bitand(rhs),
1528 }
1529 }
1530}
1531
1532impl BitAnd<&usize> for USizeVec2 {
1533 type Output = Self;
1534 #[inline]
1535 fn bitand(self, rhs: &usize) -> Self {
1536 self.bitand(*rhs)
1537 }
1538}
1539
1540impl BitAnd<&usize> for &USizeVec2 {
1541 type Output = USizeVec2;
1542 #[inline]
1543 fn bitand(self, rhs: &usize) -> USizeVec2 {
1544 (*self).bitand(*rhs)
1545 }
1546}
1547
1548impl BitAnd<usize> for &USizeVec2 {
1549 type Output = USizeVec2;
1550 #[inline]
1551 fn bitand(self, rhs: usize) -> USizeVec2 {
1552 (*self).bitand(rhs)
1553 }
1554}
1555
1556impl BitAndAssign<usize> for USizeVec2 {
1557 #[inline]
1558 fn bitand_assign(&mut self, rhs: usize) {
1559 *self = self.bitand(rhs);
1560 }
1561}
1562
1563impl BitAndAssign<&usize> for USizeVec2 {
1564 #[inline]
1565 fn bitand_assign(&mut self, rhs: &usize) {
1566 self.bitand_assign(*rhs);
1567 }
1568}
1569
1570impl BitOr<usize> for USizeVec2 {
1571 type Output = Self;
1572 #[inline]
1573 fn bitor(self, rhs: usize) -> Self::Output {
1574 Self {
1575 x: self.x.bitor(rhs),
1576 y: self.y.bitor(rhs),
1577 }
1578 }
1579}
1580
1581impl BitOr<&usize> for USizeVec2 {
1582 type Output = Self;
1583 #[inline]
1584 fn bitor(self, rhs: &usize) -> Self {
1585 self.bitor(*rhs)
1586 }
1587}
1588
1589impl BitOr<&usize> for &USizeVec2 {
1590 type Output = USizeVec2;
1591 #[inline]
1592 fn bitor(self, rhs: &usize) -> USizeVec2 {
1593 (*self).bitor(*rhs)
1594 }
1595}
1596
1597impl BitOr<usize> for &USizeVec2 {
1598 type Output = USizeVec2;
1599 #[inline]
1600 fn bitor(self, rhs: usize) -> USizeVec2 {
1601 (*self).bitor(rhs)
1602 }
1603}
1604
1605impl BitOrAssign<usize> for USizeVec2 {
1606 #[inline]
1607 fn bitor_assign(&mut self, rhs: usize) {
1608 *self = self.bitor(rhs);
1609 }
1610}
1611
1612impl BitOrAssign<&usize> for USizeVec2 {
1613 #[inline]
1614 fn bitor_assign(&mut self, rhs: &usize) {
1615 self.bitor_assign(*rhs);
1616 }
1617}
1618
1619impl BitXor<usize> for USizeVec2 {
1620 type Output = Self;
1621 #[inline]
1622 fn bitxor(self, rhs: usize) -> Self::Output {
1623 Self {
1624 x: self.x.bitxor(rhs),
1625 y: self.y.bitxor(rhs),
1626 }
1627 }
1628}
1629
1630impl BitXor<&usize> for USizeVec2 {
1631 type Output = Self;
1632 #[inline]
1633 fn bitxor(self, rhs: &usize) -> Self {
1634 self.bitxor(*rhs)
1635 }
1636}
1637
1638impl BitXor<&usize> for &USizeVec2 {
1639 type Output = USizeVec2;
1640 #[inline]
1641 fn bitxor(self, rhs: &usize) -> USizeVec2 {
1642 (*self).bitxor(*rhs)
1643 }
1644}
1645
1646impl BitXor<usize> for &USizeVec2 {
1647 type Output = USizeVec2;
1648 #[inline]
1649 fn bitxor(self, rhs: usize) -> USizeVec2 {
1650 (*self).bitxor(rhs)
1651 }
1652}
1653
1654impl BitXorAssign<usize> for USizeVec2 {
1655 #[inline]
1656 fn bitxor_assign(&mut self, rhs: usize) {
1657 *self = self.bitxor(rhs);
1658 }
1659}
1660
1661impl BitXorAssign<&usize> for USizeVec2 {
1662 #[inline]
1663 fn bitxor_assign(&mut self, rhs: &usize) {
1664 self.bitxor_assign(*rhs);
1665 }
1666}
1667
1668impl Shl<i8> for USizeVec2 {
1669 type Output = Self;
1670 #[inline]
1671 fn shl(self, rhs: i8) -> Self::Output {
1672 Self {
1673 x: self.x.shl(rhs),
1674 y: self.y.shl(rhs),
1675 }
1676 }
1677}
1678
1679impl Shl<&i8> for USizeVec2 {
1680 type Output = Self;
1681 #[inline]
1682 fn shl(self, rhs: &i8) -> Self {
1683 self.shl(*rhs)
1684 }
1685}
1686
1687impl Shl<&i8> for &USizeVec2 {
1688 type Output = USizeVec2;
1689 #[inline]
1690 fn shl(self, rhs: &i8) -> USizeVec2 {
1691 (*self).shl(*rhs)
1692 }
1693}
1694
1695impl Shl<i8> for &USizeVec2 {
1696 type Output = USizeVec2;
1697 #[inline]
1698 fn shl(self, rhs: i8) -> USizeVec2 {
1699 (*self).shl(rhs)
1700 }
1701}
1702
1703impl ShlAssign<i8> for USizeVec2 {
1704 #[inline]
1705 fn shl_assign(&mut self, rhs: i8) {
1706 *self = self.shl(rhs);
1707 }
1708}
1709
1710impl ShlAssign<&i8> for USizeVec2 {
1711 #[inline]
1712 fn shl_assign(&mut self, rhs: &i8) {
1713 self.shl_assign(*rhs);
1714 }
1715}
1716
1717impl Shr<i8> for USizeVec2 {
1718 type Output = Self;
1719 #[inline]
1720 fn shr(self, rhs: i8) -> Self::Output {
1721 Self {
1722 x: self.x.shr(rhs),
1723 y: self.y.shr(rhs),
1724 }
1725 }
1726}
1727
1728impl Shr<&i8> for USizeVec2 {
1729 type Output = Self;
1730 #[inline]
1731 fn shr(self, rhs: &i8) -> Self {
1732 self.shr(*rhs)
1733 }
1734}
1735
1736impl Shr<&i8> for &USizeVec2 {
1737 type Output = USizeVec2;
1738 #[inline]
1739 fn shr(self, rhs: &i8) -> USizeVec2 {
1740 (*self).shr(*rhs)
1741 }
1742}
1743
1744impl Shr<i8> for &USizeVec2 {
1745 type Output = USizeVec2;
1746 #[inline]
1747 fn shr(self, rhs: i8) -> USizeVec2 {
1748 (*self).shr(rhs)
1749 }
1750}
1751
1752impl ShrAssign<i8> for USizeVec2 {
1753 #[inline]
1754 fn shr_assign(&mut self, rhs: i8) {
1755 *self = self.shr(rhs);
1756 }
1757}
1758
1759impl ShrAssign<&i8> for USizeVec2 {
1760 #[inline]
1761 fn shr_assign(&mut self, rhs: &i8) {
1762 self.shr_assign(*rhs);
1763 }
1764}
1765
1766impl Shl<i16> for USizeVec2 {
1767 type Output = Self;
1768 #[inline]
1769 fn shl(self, rhs: i16) -> Self::Output {
1770 Self {
1771 x: self.x.shl(rhs),
1772 y: self.y.shl(rhs),
1773 }
1774 }
1775}
1776
1777impl Shl<&i16> for USizeVec2 {
1778 type Output = Self;
1779 #[inline]
1780 fn shl(self, rhs: &i16) -> Self {
1781 self.shl(*rhs)
1782 }
1783}
1784
1785impl Shl<&i16> for &USizeVec2 {
1786 type Output = USizeVec2;
1787 #[inline]
1788 fn shl(self, rhs: &i16) -> USizeVec2 {
1789 (*self).shl(*rhs)
1790 }
1791}
1792
1793impl Shl<i16> for &USizeVec2 {
1794 type Output = USizeVec2;
1795 #[inline]
1796 fn shl(self, rhs: i16) -> USizeVec2 {
1797 (*self).shl(rhs)
1798 }
1799}
1800
1801impl ShlAssign<i16> for USizeVec2 {
1802 #[inline]
1803 fn shl_assign(&mut self, rhs: i16) {
1804 *self = self.shl(rhs);
1805 }
1806}
1807
1808impl ShlAssign<&i16> for USizeVec2 {
1809 #[inline]
1810 fn shl_assign(&mut self, rhs: &i16) {
1811 self.shl_assign(*rhs);
1812 }
1813}
1814
1815impl Shr<i16> for USizeVec2 {
1816 type Output = Self;
1817 #[inline]
1818 fn shr(self, rhs: i16) -> Self::Output {
1819 Self {
1820 x: self.x.shr(rhs),
1821 y: self.y.shr(rhs),
1822 }
1823 }
1824}
1825
1826impl Shr<&i16> for USizeVec2 {
1827 type Output = Self;
1828 #[inline]
1829 fn shr(self, rhs: &i16) -> Self {
1830 self.shr(*rhs)
1831 }
1832}
1833
1834impl Shr<&i16> for &USizeVec2 {
1835 type Output = USizeVec2;
1836 #[inline]
1837 fn shr(self, rhs: &i16) -> USizeVec2 {
1838 (*self).shr(*rhs)
1839 }
1840}
1841
1842impl Shr<i16> for &USizeVec2 {
1843 type Output = USizeVec2;
1844 #[inline]
1845 fn shr(self, rhs: i16) -> USizeVec2 {
1846 (*self).shr(rhs)
1847 }
1848}
1849
1850impl ShrAssign<i16> for USizeVec2 {
1851 #[inline]
1852 fn shr_assign(&mut self, rhs: i16) {
1853 *self = self.shr(rhs);
1854 }
1855}
1856
1857impl ShrAssign<&i16> for USizeVec2 {
1858 #[inline]
1859 fn shr_assign(&mut self, rhs: &i16) {
1860 self.shr_assign(*rhs);
1861 }
1862}
1863
1864impl Shl<i32> for USizeVec2 {
1865 type Output = Self;
1866 #[inline]
1867 fn shl(self, rhs: i32) -> Self::Output {
1868 Self {
1869 x: self.x.shl(rhs),
1870 y: self.y.shl(rhs),
1871 }
1872 }
1873}
1874
1875impl Shl<&i32> for USizeVec2 {
1876 type Output = Self;
1877 #[inline]
1878 fn shl(self, rhs: &i32) -> Self {
1879 self.shl(*rhs)
1880 }
1881}
1882
1883impl Shl<&i32> for &USizeVec2 {
1884 type Output = USizeVec2;
1885 #[inline]
1886 fn shl(self, rhs: &i32) -> USizeVec2 {
1887 (*self).shl(*rhs)
1888 }
1889}
1890
1891impl Shl<i32> for &USizeVec2 {
1892 type Output = USizeVec2;
1893 #[inline]
1894 fn shl(self, rhs: i32) -> USizeVec2 {
1895 (*self).shl(rhs)
1896 }
1897}
1898
1899impl ShlAssign<i32> for USizeVec2 {
1900 #[inline]
1901 fn shl_assign(&mut self, rhs: i32) {
1902 *self = self.shl(rhs);
1903 }
1904}
1905
1906impl ShlAssign<&i32> for USizeVec2 {
1907 #[inline]
1908 fn shl_assign(&mut self, rhs: &i32) {
1909 self.shl_assign(*rhs);
1910 }
1911}
1912
1913impl Shr<i32> for USizeVec2 {
1914 type Output = Self;
1915 #[inline]
1916 fn shr(self, rhs: i32) -> Self::Output {
1917 Self {
1918 x: self.x.shr(rhs),
1919 y: self.y.shr(rhs),
1920 }
1921 }
1922}
1923
1924impl Shr<&i32> for USizeVec2 {
1925 type Output = Self;
1926 #[inline]
1927 fn shr(self, rhs: &i32) -> Self {
1928 self.shr(*rhs)
1929 }
1930}
1931
1932impl Shr<&i32> for &USizeVec2 {
1933 type Output = USizeVec2;
1934 #[inline]
1935 fn shr(self, rhs: &i32) -> USizeVec2 {
1936 (*self).shr(*rhs)
1937 }
1938}
1939
1940impl Shr<i32> for &USizeVec2 {
1941 type Output = USizeVec2;
1942 #[inline]
1943 fn shr(self, rhs: i32) -> USizeVec2 {
1944 (*self).shr(rhs)
1945 }
1946}
1947
1948impl ShrAssign<i32> for USizeVec2 {
1949 #[inline]
1950 fn shr_assign(&mut self, rhs: i32) {
1951 *self = self.shr(rhs);
1952 }
1953}
1954
1955impl ShrAssign<&i32> for USizeVec2 {
1956 #[inline]
1957 fn shr_assign(&mut self, rhs: &i32) {
1958 self.shr_assign(*rhs);
1959 }
1960}
1961
1962impl Shl<i64> for USizeVec2 {
1963 type Output = Self;
1964 #[inline]
1965 fn shl(self, rhs: i64) -> Self::Output {
1966 Self {
1967 x: self.x.shl(rhs),
1968 y: self.y.shl(rhs),
1969 }
1970 }
1971}
1972
1973impl Shl<&i64> for USizeVec2 {
1974 type Output = Self;
1975 #[inline]
1976 fn shl(self, rhs: &i64) -> Self {
1977 self.shl(*rhs)
1978 }
1979}
1980
1981impl Shl<&i64> for &USizeVec2 {
1982 type Output = USizeVec2;
1983 #[inline]
1984 fn shl(self, rhs: &i64) -> USizeVec2 {
1985 (*self).shl(*rhs)
1986 }
1987}
1988
1989impl Shl<i64> for &USizeVec2 {
1990 type Output = USizeVec2;
1991 #[inline]
1992 fn shl(self, rhs: i64) -> USizeVec2 {
1993 (*self).shl(rhs)
1994 }
1995}
1996
1997impl ShlAssign<i64> for USizeVec2 {
1998 #[inline]
1999 fn shl_assign(&mut self, rhs: i64) {
2000 *self = self.shl(rhs);
2001 }
2002}
2003
2004impl ShlAssign<&i64> for USizeVec2 {
2005 #[inline]
2006 fn shl_assign(&mut self, rhs: &i64) {
2007 self.shl_assign(*rhs);
2008 }
2009}
2010
2011impl Shr<i64> for USizeVec2 {
2012 type Output = Self;
2013 #[inline]
2014 fn shr(self, rhs: i64) -> Self::Output {
2015 Self {
2016 x: self.x.shr(rhs),
2017 y: self.y.shr(rhs),
2018 }
2019 }
2020}
2021
2022impl Shr<&i64> for USizeVec2 {
2023 type Output = Self;
2024 #[inline]
2025 fn shr(self, rhs: &i64) -> Self {
2026 self.shr(*rhs)
2027 }
2028}
2029
2030impl Shr<&i64> for &USizeVec2 {
2031 type Output = USizeVec2;
2032 #[inline]
2033 fn shr(self, rhs: &i64) -> USizeVec2 {
2034 (*self).shr(*rhs)
2035 }
2036}
2037
2038impl Shr<i64> for &USizeVec2 {
2039 type Output = USizeVec2;
2040 #[inline]
2041 fn shr(self, rhs: i64) -> USizeVec2 {
2042 (*self).shr(rhs)
2043 }
2044}
2045
2046impl ShrAssign<i64> for USizeVec2 {
2047 #[inline]
2048 fn shr_assign(&mut self, rhs: i64) {
2049 *self = self.shr(rhs);
2050 }
2051}
2052
2053impl ShrAssign<&i64> for USizeVec2 {
2054 #[inline]
2055 fn shr_assign(&mut self, rhs: &i64) {
2056 self.shr_assign(*rhs);
2057 }
2058}
2059
2060impl Shl<u8> for USizeVec2 {
2061 type Output = Self;
2062 #[inline]
2063 fn shl(self, rhs: u8) -> Self::Output {
2064 Self {
2065 x: self.x.shl(rhs),
2066 y: self.y.shl(rhs),
2067 }
2068 }
2069}
2070
2071impl Shl<&u8> for USizeVec2 {
2072 type Output = Self;
2073 #[inline]
2074 fn shl(self, rhs: &u8) -> Self {
2075 self.shl(*rhs)
2076 }
2077}
2078
2079impl Shl<&u8> for &USizeVec2 {
2080 type Output = USizeVec2;
2081 #[inline]
2082 fn shl(self, rhs: &u8) -> USizeVec2 {
2083 (*self).shl(*rhs)
2084 }
2085}
2086
2087impl Shl<u8> for &USizeVec2 {
2088 type Output = USizeVec2;
2089 #[inline]
2090 fn shl(self, rhs: u8) -> USizeVec2 {
2091 (*self).shl(rhs)
2092 }
2093}
2094
2095impl ShlAssign<u8> for USizeVec2 {
2096 #[inline]
2097 fn shl_assign(&mut self, rhs: u8) {
2098 *self = self.shl(rhs);
2099 }
2100}
2101
2102impl ShlAssign<&u8> for USizeVec2 {
2103 #[inline]
2104 fn shl_assign(&mut self, rhs: &u8) {
2105 self.shl_assign(*rhs);
2106 }
2107}
2108
2109impl Shr<u8> for USizeVec2 {
2110 type Output = Self;
2111 #[inline]
2112 fn shr(self, rhs: u8) -> Self::Output {
2113 Self {
2114 x: self.x.shr(rhs),
2115 y: self.y.shr(rhs),
2116 }
2117 }
2118}
2119
2120impl Shr<&u8> for USizeVec2 {
2121 type Output = Self;
2122 #[inline]
2123 fn shr(self, rhs: &u8) -> Self {
2124 self.shr(*rhs)
2125 }
2126}
2127
2128impl Shr<&u8> for &USizeVec2 {
2129 type Output = USizeVec2;
2130 #[inline]
2131 fn shr(self, rhs: &u8) -> USizeVec2 {
2132 (*self).shr(*rhs)
2133 }
2134}
2135
2136impl Shr<u8> for &USizeVec2 {
2137 type Output = USizeVec2;
2138 #[inline]
2139 fn shr(self, rhs: u8) -> USizeVec2 {
2140 (*self).shr(rhs)
2141 }
2142}
2143
2144impl ShrAssign<u8> for USizeVec2 {
2145 #[inline]
2146 fn shr_assign(&mut self, rhs: u8) {
2147 *self = self.shr(rhs);
2148 }
2149}
2150
2151impl ShrAssign<&u8> for USizeVec2 {
2152 #[inline]
2153 fn shr_assign(&mut self, rhs: &u8) {
2154 self.shr_assign(*rhs);
2155 }
2156}
2157
2158impl Shl<u16> for USizeVec2 {
2159 type Output = Self;
2160 #[inline]
2161 fn shl(self, rhs: u16) -> Self::Output {
2162 Self {
2163 x: self.x.shl(rhs),
2164 y: self.y.shl(rhs),
2165 }
2166 }
2167}
2168
2169impl Shl<&u16> for USizeVec2 {
2170 type Output = Self;
2171 #[inline]
2172 fn shl(self, rhs: &u16) -> Self {
2173 self.shl(*rhs)
2174 }
2175}
2176
2177impl Shl<&u16> for &USizeVec2 {
2178 type Output = USizeVec2;
2179 #[inline]
2180 fn shl(self, rhs: &u16) -> USizeVec2 {
2181 (*self).shl(*rhs)
2182 }
2183}
2184
2185impl Shl<u16> for &USizeVec2 {
2186 type Output = USizeVec2;
2187 #[inline]
2188 fn shl(self, rhs: u16) -> USizeVec2 {
2189 (*self).shl(rhs)
2190 }
2191}
2192
2193impl ShlAssign<u16> for USizeVec2 {
2194 #[inline]
2195 fn shl_assign(&mut self, rhs: u16) {
2196 *self = self.shl(rhs);
2197 }
2198}
2199
2200impl ShlAssign<&u16> for USizeVec2 {
2201 #[inline]
2202 fn shl_assign(&mut self, rhs: &u16) {
2203 self.shl_assign(*rhs);
2204 }
2205}
2206
2207impl Shr<u16> for USizeVec2 {
2208 type Output = Self;
2209 #[inline]
2210 fn shr(self, rhs: u16) -> Self::Output {
2211 Self {
2212 x: self.x.shr(rhs),
2213 y: self.y.shr(rhs),
2214 }
2215 }
2216}
2217
2218impl Shr<&u16> for USizeVec2 {
2219 type Output = Self;
2220 #[inline]
2221 fn shr(self, rhs: &u16) -> Self {
2222 self.shr(*rhs)
2223 }
2224}
2225
2226impl Shr<&u16> for &USizeVec2 {
2227 type Output = USizeVec2;
2228 #[inline]
2229 fn shr(self, rhs: &u16) -> USizeVec2 {
2230 (*self).shr(*rhs)
2231 }
2232}
2233
2234impl Shr<u16> for &USizeVec2 {
2235 type Output = USizeVec2;
2236 #[inline]
2237 fn shr(self, rhs: u16) -> USizeVec2 {
2238 (*self).shr(rhs)
2239 }
2240}
2241
2242impl ShrAssign<u16> for USizeVec2 {
2243 #[inline]
2244 fn shr_assign(&mut self, rhs: u16) {
2245 *self = self.shr(rhs);
2246 }
2247}
2248
2249impl ShrAssign<&u16> for USizeVec2 {
2250 #[inline]
2251 fn shr_assign(&mut self, rhs: &u16) {
2252 self.shr_assign(*rhs);
2253 }
2254}
2255
2256impl Shl<u32> for USizeVec2 {
2257 type Output = Self;
2258 #[inline]
2259 fn shl(self, rhs: u32) -> Self::Output {
2260 Self {
2261 x: self.x.shl(rhs),
2262 y: self.y.shl(rhs),
2263 }
2264 }
2265}
2266
2267impl Shl<&u32> for USizeVec2 {
2268 type Output = Self;
2269 #[inline]
2270 fn shl(self, rhs: &u32) -> Self {
2271 self.shl(*rhs)
2272 }
2273}
2274
2275impl Shl<&u32> for &USizeVec2 {
2276 type Output = USizeVec2;
2277 #[inline]
2278 fn shl(self, rhs: &u32) -> USizeVec2 {
2279 (*self).shl(*rhs)
2280 }
2281}
2282
2283impl Shl<u32> for &USizeVec2 {
2284 type Output = USizeVec2;
2285 #[inline]
2286 fn shl(self, rhs: u32) -> USizeVec2 {
2287 (*self).shl(rhs)
2288 }
2289}
2290
2291impl ShlAssign<u32> for USizeVec2 {
2292 #[inline]
2293 fn shl_assign(&mut self, rhs: u32) {
2294 *self = self.shl(rhs);
2295 }
2296}
2297
2298impl ShlAssign<&u32> for USizeVec2 {
2299 #[inline]
2300 fn shl_assign(&mut self, rhs: &u32) {
2301 self.shl_assign(*rhs);
2302 }
2303}
2304
2305impl Shr<u32> for USizeVec2 {
2306 type Output = Self;
2307 #[inline]
2308 fn shr(self, rhs: u32) -> Self::Output {
2309 Self {
2310 x: self.x.shr(rhs),
2311 y: self.y.shr(rhs),
2312 }
2313 }
2314}
2315
2316impl Shr<&u32> for USizeVec2 {
2317 type Output = Self;
2318 #[inline]
2319 fn shr(self, rhs: &u32) -> Self {
2320 self.shr(*rhs)
2321 }
2322}
2323
2324impl Shr<&u32> for &USizeVec2 {
2325 type Output = USizeVec2;
2326 #[inline]
2327 fn shr(self, rhs: &u32) -> USizeVec2 {
2328 (*self).shr(*rhs)
2329 }
2330}
2331
2332impl Shr<u32> for &USizeVec2 {
2333 type Output = USizeVec2;
2334 #[inline]
2335 fn shr(self, rhs: u32) -> USizeVec2 {
2336 (*self).shr(rhs)
2337 }
2338}
2339
2340impl ShrAssign<u32> for USizeVec2 {
2341 #[inline]
2342 fn shr_assign(&mut self, rhs: u32) {
2343 *self = self.shr(rhs);
2344 }
2345}
2346
2347impl ShrAssign<&u32> for USizeVec2 {
2348 #[inline]
2349 fn shr_assign(&mut self, rhs: &u32) {
2350 self.shr_assign(*rhs);
2351 }
2352}
2353
2354impl Shl<u64> for USizeVec2 {
2355 type Output = Self;
2356 #[inline]
2357 fn shl(self, rhs: u64) -> Self::Output {
2358 Self {
2359 x: self.x.shl(rhs),
2360 y: self.y.shl(rhs),
2361 }
2362 }
2363}
2364
2365impl Shl<&u64> for USizeVec2 {
2366 type Output = Self;
2367 #[inline]
2368 fn shl(self, rhs: &u64) -> Self {
2369 self.shl(*rhs)
2370 }
2371}
2372
2373impl Shl<&u64> for &USizeVec2 {
2374 type Output = USizeVec2;
2375 #[inline]
2376 fn shl(self, rhs: &u64) -> USizeVec2 {
2377 (*self).shl(*rhs)
2378 }
2379}
2380
2381impl Shl<u64> for &USizeVec2 {
2382 type Output = USizeVec2;
2383 #[inline]
2384 fn shl(self, rhs: u64) -> USizeVec2 {
2385 (*self).shl(rhs)
2386 }
2387}
2388
2389impl ShlAssign<u64> for USizeVec2 {
2390 #[inline]
2391 fn shl_assign(&mut self, rhs: u64) {
2392 *self = self.shl(rhs);
2393 }
2394}
2395
2396impl ShlAssign<&u64> for USizeVec2 {
2397 #[inline]
2398 fn shl_assign(&mut self, rhs: &u64) {
2399 self.shl_assign(*rhs);
2400 }
2401}
2402
2403impl Shr<u64> for USizeVec2 {
2404 type Output = Self;
2405 #[inline]
2406 fn shr(self, rhs: u64) -> Self::Output {
2407 Self {
2408 x: self.x.shr(rhs),
2409 y: self.y.shr(rhs),
2410 }
2411 }
2412}
2413
2414impl Shr<&u64> for USizeVec2 {
2415 type Output = Self;
2416 #[inline]
2417 fn shr(self, rhs: &u64) -> Self {
2418 self.shr(*rhs)
2419 }
2420}
2421
2422impl Shr<&u64> for &USizeVec2 {
2423 type Output = USizeVec2;
2424 #[inline]
2425 fn shr(self, rhs: &u64) -> USizeVec2 {
2426 (*self).shr(*rhs)
2427 }
2428}
2429
2430impl Shr<u64> for &USizeVec2 {
2431 type Output = USizeVec2;
2432 #[inline]
2433 fn shr(self, rhs: u64) -> USizeVec2 {
2434 (*self).shr(rhs)
2435 }
2436}
2437
2438impl ShrAssign<u64> for USizeVec2 {
2439 #[inline]
2440 fn shr_assign(&mut self, rhs: u64) {
2441 *self = self.shr(rhs);
2442 }
2443}
2444
2445impl ShrAssign<&u64> for USizeVec2 {
2446 #[inline]
2447 fn shr_assign(&mut self, rhs: &u64) {
2448 self.shr_assign(*rhs);
2449 }
2450}
2451
2452impl Shl<IVec2> for USizeVec2 {
2453 type Output = Self;
2454 #[inline]
2455 fn shl(self, rhs: IVec2) -> Self {
2456 Self {
2457 x: self.x.shl(rhs.x),
2458 y: self.y.shl(rhs.y),
2459 }
2460 }
2461}
2462
2463impl Shl<&IVec2> for USizeVec2 {
2464 type Output = Self;
2465 #[inline]
2466 fn shl(self, rhs: &IVec2) -> Self {
2467 self.shl(*rhs)
2468 }
2469}
2470
2471impl Shl<&IVec2> for &USizeVec2 {
2472 type Output = USizeVec2;
2473 #[inline]
2474 fn shl(self, rhs: &IVec2) -> USizeVec2 {
2475 (*self).shl(*rhs)
2476 }
2477}
2478
2479impl Shl<IVec2> for &USizeVec2 {
2480 type Output = USizeVec2;
2481 #[inline]
2482 fn shl(self, rhs: IVec2) -> USizeVec2 {
2483 (*self).shl(rhs)
2484 }
2485}
2486
2487impl Shr<IVec2> for USizeVec2 {
2488 type Output = Self;
2489 #[inline]
2490 fn shr(self, rhs: IVec2) -> Self {
2491 Self {
2492 x: self.x.shr(rhs.x),
2493 y: self.y.shr(rhs.y),
2494 }
2495 }
2496}
2497
2498impl Shr<&IVec2> for USizeVec2 {
2499 type Output = Self;
2500 #[inline]
2501 fn shr(self, rhs: &IVec2) -> Self {
2502 self.shr(*rhs)
2503 }
2504}
2505
2506impl Shr<&IVec2> for &USizeVec2 {
2507 type Output = USizeVec2;
2508 #[inline]
2509 fn shr(self, rhs: &IVec2) -> USizeVec2 {
2510 (*self).shr(*rhs)
2511 }
2512}
2513
2514impl Shr<IVec2> for &USizeVec2 {
2515 type Output = USizeVec2;
2516 #[inline]
2517 fn shr(self, rhs: IVec2) -> USizeVec2 {
2518 (*self).shr(rhs)
2519 }
2520}
2521
2522impl Shl<UVec2> for USizeVec2 {
2523 type Output = Self;
2524 #[inline]
2525 fn shl(self, rhs: UVec2) -> Self {
2526 Self {
2527 x: self.x.shl(rhs.x),
2528 y: self.y.shl(rhs.y),
2529 }
2530 }
2531}
2532
2533impl Shl<&UVec2> for USizeVec2 {
2534 type Output = Self;
2535 #[inline]
2536 fn shl(self, rhs: &UVec2) -> Self {
2537 self.shl(*rhs)
2538 }
2539}
2540
2541impl Shl<&UVec2> for &USizeVec2 {
2542 type Output = USizeVec2;
2543 #[inline]
2544 fn shl(self, rhs: &UVec2) -> USizeVec2 {
2545 (*self).shl(*rhs)
2546 }
2547}
2548
2549impl Shl<UVec2> for &USizeVec2 {
2550 type Output = USizeVec2;
2551 #[inline]
2552 fn shl(self, rhs: UVec2) -> USizeVec2 {
2553 (*self).shl(rhs)
2554 }
2555}
2556
2557impl Shr<UVec2> for USizeVec2 {
2558 type Output = Self;
2559 #[inline]
2560 fn shr(self, rhs: UVec2) -> Self {
2561 Self {
2562 x: self.x.shr(rhs.x),
2563 y: self.y.shr(rhs.y),
2564 }
2565 }
2566}
2567
2568impl Shr<&UVec2> for USizeVec2 {
2569 type Output = Self;
2570 #[inline]
2571 fn shr(self, rhs: &UVec2) -> Self {
2572 self.shr(*rhs)
2573 }
2574}
2575
2576impl Shr<&UVec2> for &USizeVec2 {
2577 type Output = USizeVec2;
2578 #[inline]
2579 fn shr(self, rhs: &UVec2) -> USizeVec2 {
2580 (*self).shr(*rhs)
2581 }
2582}
2583
2584impl Shr<UVec2> for &USizeVec2 {
2585 type Output = USizeVec2;
2586 #[inline]
2587 fn shr(self, rhs: UVec2) -> USizeVec2 {
2588 (*self).shr(rhs)
2589 }
2590}
2591
2592impl Index<usize> for USizeVec2 {
2593 type Output = usize;
2594 #[inline]
2595 fn index(&self, index: usize) -> &Self::Output {
2596 match index {
2597 0 => &self.x,
2598 1 => &self.y,
2599 _ => panic!("index out of bounds"),
2600 }
2601 }
2602}
2603
2604impl IndexMut<usize> for USizeVec2 {
2605 #[inline]
2606 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
2607 match index {
2608 0 => &mut self.x,
2609 1 => &mut self.y,
2610 _ => panic!("index out of bounds"),
2611 }
2612 }
2613}
2614
2615impl fmt::Display for USizeVec2 {
2616 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2617 write!(f, "[{}, {}]", self.x, self.y)
2618 }
2619}
2620
2621impl fmt::Debug for USizeVec2 {
2622 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2623 fmt.debug_tuple(stringify!(USizeVec2))
2624 .field(&self.x)
2625 .field(&self.y)
2626 .finish()
2627 }
2628}
2629
2630impl From<[usize; 2]> for USizeVec2 {
2631 #[inline]
2632 fn from(a: [usize; 2]) -> Self {
2633 Self::new(a[0], a[1])
2634 }
2635}
2636
2637impl From<USizeVec2> for [usize; 2] {
2638 #[inline]
2639 fn from(v: USizeVec2) -> Self {
2640 [v.x, v.y]
2641 }
2642}
2643
2644impl From<(usize, usize)> for USizeVec2 {
2645 #[inline]
2646 fn from(t: (usize, usize)) -> Self {
2647 Self::new(t.0, t.1)
2648 }
2649}
2650
2651impl From<USizeVec2> for (usize, usize) {
2652 #[inline]
2653 fn from(v: USizeVec2) -> Self {
2654 (v.x, v.y)
2655 }
2656}
2657
2658impl From<U8Vec2> for USizeVec2 {
2659 #[inline]
2660 fn from(v: U8Vec2) -> Self {
2661 Self::new(usize::from(v.x), usize::from(v.y))
2662 }
2663}
2664
2665impl From<U16Vec2> for USizeVec2 {
2666 #[inline]
2667 fn from(v: U16Vec2) -> Self {
2668 Self::new(usize::from(v.x), usize::from(v.y))
2669 }
2670}
2671
2672impl TryFrom<I8Vec2> for USizeVec2 {
2673 type Error = core::num::TryFromIntError;
2674
2675 #[inline]
2676 fn try_from(v: I8Vec2) -> Result<Self, Self::Error> {
2677 Ok(Self::new(usize::try_from(v.x)?, usize::try_from(v.y)?))
2678 }
2679}
2680
2681impl TryFrom<I16Vec2> for USizeVec2 {
2682 type Error = core::num::TryFromIntError;
2683
2684 #[inline]
2685 fn try_from(v: I16Vec2) -> Result<Self, Self::Error> {
2686 Ok(Self::new(usize::try_from(v.x)?, usize::try_from(v.y)?))
2687 }
2688}
2689
2690impl TryFrom<IVec2> for USizeVec2 {
2691 type Error = core::num::TryFromIntError;
2692
2693 #[inline]
2694 fn try_from(v: IVec2) -> Result<Self, Self::Error> {
2695 Ok(Self::new(usize::try_from(v.x)?, usize::try_from(v.y)?))
2696 }
2697}
2698
2699impl TryFrom<I64Vec2> for USizeVec2 {
2700 type Error = core::num::TryFromIntError;
2701
2702 #[inline]
2703 fn try_from(v: I64Vec2) -> Result<Self, Self::Error> {
2704 Ok(Self::new(usize::try_from(v.x)?, usize::try_from(v.y)?))
2705 }
2706}
2707
2708impl TryFrom<UVec2> for USizeVec2 {
2709 type Error = core::num::TryFromIntError;
2710
2711 #[inline]
2712 fn try_from(v: UVec2) -> Result<Self, Self::Error> {
2713 Ok(Self::new(usize::try_from(v.x)?, usize::try_from(v.y)?))
2714 }
2715}
2716
2717impl TryFrom<U64Vec2> for USizeVec2 {
2718 type Error = core::num::TryFromIntError;
2719
2720 #[inline]
2721 fn try_from(v: U64Vec2) -> Result<Self, Self::Error> {
2722 Ok(Self::new(usize::try_from(v.x)?, usize::try_from(v.y)?))
2723 }
2724}
2725
2726impl From<BVec2> for USizeVec2 {
2727 #[inline]
2728 fn from(v: BVec2) -> Self {
2729 Self::new(usize::from(v.x), usize::from(v.y))
2730 }
2731}