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