glam/i32/
ivec2.rs

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