Skip to main content

glam/i32/
ivec2.rs

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