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