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