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, 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#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
18#[derive(Clone, Copy, PartialEq, Eq)]
19#[cfg_attr(feature = "cuda", repr(align(8)))]
20#[cfg_attr(not(target_arch = "spirv"), repr(C))]
21#[cfg_attr(target_arch = "spirv", repr(simd))]
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    /// `[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 `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
172    #[inline]
173    #[must_use]
174    pub fn min(self, rhs: Self) -> Self {
175        Self {
176            x: self.x.min(rhs.x),
177            y: self.y.min(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 `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
184    #[inline]
185    #[must_use]
186    pub fn max(self, rhs: Self) -> Self {
187        Self {
188            x: self.x.max(rhs.x),
189            y: self.y.max(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        self.x.min(self.y)
214    }
215
216    /// Returns the horizontal maximum of `self`.
217    ///
218    /// In other words this computes `max(x, y, ..)`.
219    #[inline]
220    #[must_use]
221    pub fn max_element(self) -> i32 {
222        self.x.max(self.y)
223    }
224
225    /// Returns the sum of all elements of `self`.
226    ///
227    /// In other words, this computes `self.x + self.y + ..`.
228    #[inline]
229    #[must_use]
230    pub fn element_sum(self) -> i32 {
231        self.x + self.y
232    }
233
234    /// Returns the product of all elements of `self`.
235    ///
236    /// In other words, this computes `self.x * self.y * ..`.
237    #[inline]
238    #[must_use]
239    pub fn element_product(self) -> i32 {
240        self.x * self.y
241    }
242
243    /// Returns a vector mask containing the result of a `==` comparison for each element of
244    /// `self` and `rhs`.
245    ///
246    /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
247    /// elements.
248    #[inline]
249    #[must_use]
250    pub fn cmpeq(self, rhs: Self) -> BVec2 {
251        BVec2::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y))
252    }
253
254    /// Returns a vector mask containing the result of a `!=` comparison for each element of
255    /// `self` and `rhs`.
256    ///
257    /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
258    /// elements.
259    #[inline]
260    #[must_use]
261    pub fn cmpne(self, rhs: Self) -> BVec2 {
262        BVec2::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y))
263    }
264
265    /// Returns a vector mask containing the result of a `>=` comparison for each element of
266    /// `self` and `rhs`.
267    ///
268    /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
269    /// elements.
270    #[inline]
271    #[must_use]
272    pub fn cmpge(self, rhs: Self) -> BVec2 {
273        BVec2::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y))
274    }
275
276    /// Returns a vector mask containing the result of a `>` comparison for each element of
277    /// `self` and `rhs`.
278    ///
279    /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
280    /// elements.
281    #[inline]
282    #[must_use]
283    pub fn cmpgt(self, rhs: Self) -> BVec2 {
284        BVec2::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y))
285    }
286
287    /// Returns a vector mask containing the result of a `<=` comparison for each element of
288    /// `self` and `rhs`.
289    ///
290    /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
291    /// elements.
292    #[inline]
293    #[must_use]
294    pub fn cmple(self, rhs: Self) -> BVec2 {
295        BVec2::new(self.x.le(&rhs.x), self.y.le(&rhs.y))
296    }
297
298    /// Returns a vector mask containing the result of a `<` comparison for each element of
299    /// `self` and `rhs`.
300    ///
301    /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
302    /// elements.
303    #[inline]
304    #[must_use]
305    pub fn cmplt(self, rhs: Self) -> BVec2 {
306        BVec2::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y))
307    }
308
309    /// Returns a vector containing the absolute value of each element of `self`.
310    #[inline]
311    #[must_use]
312    pub fn abs(self) -> Self {
313        Self {
314            x: self.x.abs(),
315            y: self.y.abs(),
316        }
317    }
318
319    /// Returns a vector with elements representing the sign of `self`.
320    ///
321    ///  - `0` if the number is zero
322    ///  - `1` if the number is positive
323    ///  - `-1` if the number is negative
324    #[inline]
325    #[must_use]
326    pub fn signum(self) -> Self {
327        Self {
328            x: self.x.signum(),
329            y: self.y.signum(),
330        }
331    }
332
333    /// Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`.
334    ///
335    /// A negative element results in a `1` bit and a positive element in a `0` bit.  Element `x` goes
336    /// into the first lowest bit, element `y` into the second, etc.
337    #[inline]
338    #[must_use]
339    pub fn is_negative_bitmask(self) -> u32 {
340        (self.x.is_negative() as u32) | (self.y.is_negative() as u32) << 1
341    }
342
343    /// Computes the squared length of `self`.
344    #[doc(alias = "magnitude2")]
345    #[inline]
346    #[must_use]
347    pub fn length_squared(self) -> i32 {
348        self.dot(self)
349    }
350
351    /// Compute the squared euclidean distance between two points in space.
352    #[inline]
353    #[must_use]
354    pub fn distance_squared(self, rhs: Self) -> i32 {
355        (self - rhs).length_squared()
356    }
357
358    /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
359    ///
360    /// # Panics
361    /// This function will panic if any `rhs` element is 0 or the division results in overflow.
362    #[inline]
363    #[must_use]
364    pub fn div_euclid(self, rhs: Self) -> Self {
365        Self::new(self.x.div_euclid(rhs.x), self.y.div_euclid(rhs.y))
366    }
367
368    /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`.
369    ///
370    /// # Panics
371    /// This function will panic if any `rhs` element is 0 or the division results in overflow.
372    ///
373    /// [Euclidean division]: i32::rem_euclid
374    #[inline]
375    #[must_use]
376    pub fn rem_euclid(self, rhs: Self) -> Self {
377        Self::new(self.x.rem_euclid(rhs.x), self.y.rem_euclid(rhs.y))
378    }
379
380    /// Returns a vector that is equal to `self` rotated by 90 degrees.
381    #[inline]
382    #[must_use]
383    pub fn perp(self) -> Self {
384        Self {
385            x: -self.y,
386            y: self.x,
387        }
388    }
389
390    /// The perpendicular dot product of `self` and `rhs`.
391    /// Also known as the wedge product, 2D cross product, and determinant.
392    #[doc(alias = "wedge")]
393    #[doc(alias = "cross")]
394    #[doc(alias = "determinant")]
395    #[inline]
396    #[must_use]
397    pub fn perp_dot(self, rhs: Self) -> i32 {
398        (self.x * rhs.y) - (self.y * rhs.x)
399    }
400
401    /// Returns `rhs` rotated by the angle of `self`. If `self` is normalized,
402    /// then this just rotation. This is what you usually want. Otherwise,
403    /// it will be like a rotation with a multiplication by `self`'s length.
404    #[inline]
405    #[must_use]
406    pub fn rotate(self, rhs: Self) -> Self {
407        Self {
408            x: self.x * rhs.x - self.y * rhs.y,
409            y: self.y * rhs.x + self.x * rhs.y,
410        }
411    }
412
413    /// Casts all elements of `self` to `f32`.
414    #[inline]
415    #[must_use]
416    pub fn as_vec2(&self) -> crate::Vec2 {
417        crate::Vec2::new(self.x as f32, self.y as f32)
418    }
419
420    /// Casts all elements of `self` to `f64`.
421    #[inline]
422    #[must_use]
423    pub fn as_dvec2(&self) -> crate::DVec2 {
424        crate::DVec2::new(self.x as f64, self.y as f64)
425    }
426
427    /// Casts all elements of `self` to `i8`.
428    #[inline]
429    #[must_use]
430    pub fn as_i8vec2(&self) -> crate::I8Vec2 {
431        crate::I8Vec2::new(self.x as i8, self.y as i8)
432    }
433
434    /// Casts all elements of `self` to `u8`.
435    #[inline]
436    #[must_use]
437    pub fn as_u8vec2(&self) -> crate::U8Vec2 {
438        crate::U8Vec2::new(self.x as u8, self.y as u8)
439    }
440
441    /// Casts all elements of `self` to `i16`.
442    #[inline]
443    #[must_use]
444    pub fn as_i16vec2(&self) -> crate::I16Vec2 {
445        crate::I16Vec2::new(self.x as i16, self.y as i16)
446    }
447
448    /// Casts all elements of `self` to `u16`.
449    #[inline]
450    #[must_use]
451    pub fn as_u16vec2(&self) -> crate::U16Vec2 {
452        crate::U16Vec2::new(self.x as u16, self.y as u16)
453    }
454
455    /// Casts all elements of `self` to `u32`.
456    #[inline]
457    #[must_use]
458    pub fn as_uvec2(&self) -> crate::UVec2 {
459        crate::UVec2::new(self.x as u32, self.y as u32)
460    }
461
462    /// Casts all elements of `self` to `i64`.
463    #[inline]
464    #[must_use]
465    pub fn as_i64vec2(&self) -> crate::I64Vec2 {
466        crate::I64Vec2::new(self.x as i64, self.y as i64)
467    }
468
469    /// Casts all elements of `self` to `u64`.
470    #[inline]
471    #[must_use]
472    pub fn as_u64vec2(&self) -> crate::U64Vec2 {
473        crate::U64Vec2::new(self.x as u64, self.y as u64)
474    }
475
476    /// Returns a vector containing the wrapping addition of `self` and `rhs`.
477    ///
478    /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
479    #[inline]
480    #[must_use]
481    pub const fn wrapping_add(self, rhs: Self) -> Self {
482        Self {
483            x: self.x.wrapping_add(rhs.x),
484            y: self.y.wrapping_add(rhs.y),
485        }
486    }
487
488    /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
489    ///
490    /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
491    #[inline]
492    #[must_use]
493    pub const fn wrapping_sub(self, rhs: Self) -> Self {
494        Self {
495            x: self.x.wrapping_sub(rhs.x),
496            y: self.y.wrapping_sub(rhs.y),
497        }
498    }
499
500    /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
501    ///
502    /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
503    #[inline]
504    #[must_use]
505    pub const fn wrapping_mul(self, rhs: Self) -> Self {
506        Self {
507            x: self.x.wrapping_mul(rhs.x),
508            y: self.y.wrapping_mul(rhs.y),
509        }
510    }
511
512    /// Returns a vector containing the wrapping division of `self` and `rhs`.
513    ///
514    /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
515    #[inline]
516    #[must_use]
517    pub const fn wrapping_div(self, rhs: Self) -> Self {
518        Self {
519            x: self.x.wrapping_div(rhs.x),
520            y: self.y.wrapping_div(rhs.y),
521        }
522    }
523
524    /// Returns a vector containing the saturating addition of `self` and `rhs`.
525    ///
526    /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
527    #[inline]
528    #[must_use]
529    pub const fn saturating_add(self, rhs: Self) -> Self {
530        Self {
531            x: self.x.saturating_add(rhs.x),
532            y: self.y.saturating_add(rhs.y),
533        }
534    }
535
536    /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
537    ///
538    /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
539    #[inline]
540    #[must_use]
541    pub const fn saturating_sub(self, rhs: Self) -> Self {
542        Self {
543            x: self.x.saturating_sub(rhs.x),
544            y: self.y.saturating_sub(rhs.y),
545        }
546    }
547
548    /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
549    ///
550    /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
551    #[inline]
552    #[must_use]
553    pub const fn saturating_mul(self, rhs: Self) -> Self {
554        Self {
555            x: self.x.saturating_mul(rhs.x),
556            y: self.y.saturating_mul(rhs.y),
557        }
558    }
559
560    /// Returns a vector containing the saturating division of `self` and `rhs`.
561    ///
562    /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
563    #[inline]
564    #[must_use]
565    pub const fn saturating_div(self, rhs: Self) -> Self {
566        Self {
567            x: self.x.saturating_div(rhs.x),
568            y: self.y.saturating_div(rhs.y),
569        }
570    }
571
572    /// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`.
573    ///
574    /// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`.
575    #[inline]
576    #[must_use]
577    pub const fn wrapping_add_unsigned(self, rhs: UVec2) -> Self {
578        Self {
579            x: self.x.wrapping_add_unsigned(rhs.x),
580            y: self.y.wrapping_add_unsigned(rhs.y),
581        }
582    }
583
584    /// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`.
585    ///
586    /// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`.
587    #[inline]
588    #[must_use]
589    pub const fn wrapping_sub_unsigned(self, rhs: UVec2) -> Self {
590        Self {
591            x: self.x.wrapping_sub_unsigned(rhs.x),
592            y: self.y.wrapping_sub_unsigned(rhs.y),
593        }
594    }
595
596    // Returns a vector containing the saturating addition of `self` and unsigned vector `rhs`.
597    ///
598    /// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
599    #[inline]
600    #[must_use]
601    pub const fn saturating_add_unsigned(self, rhs: UVec2) -> Self {
602        Self {
603            x: self.x.saturating_add_unsigned(rhs.x),
604            y: self.y.saturating_add_unsigned(rhs.y),
605        }
606    }
607
608    /// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`.
609    ///
610    /// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`.
611    #[inline]
612    #[must_use]
613    pub const fn saturating_sub_unsigned(self, rhs: UVec2) -> Self {
614        Self {
615            x: self.x.saturating_sub_unsigned(rhs.x),
616            y: self.y.saturating_sub_unsigned(rhs.y),
617        }
618    }
619}
620
621impl Default for IVec2 {
622    #[inline(always)]
623    fn default() -> Self {
624        Self::ZERO
625    }
626}
627
628impl Div<IVec2> for IVec2 {
629    type Output = Self;
630    #[inline]
631    fn div(self, rhs: Self) -> Self {
632        Self {
633            x: self.x.div(rhs.x),
634            y: self.y.div(rhs.y),
635        }
636    }
637}
638
639impl Div<&IVec2> for IVec2 {
640    type Output = IVec2;
641    #[inline]
642    fn div(self, rhs: &IVec2) -> IVec2 {
643        self.div(*rhs)
644    }
645}
646
647impl Div<&IVec2> for &IVec2 {
648    type Output = IVec2;
649    #[inline]
650    fn div(self, rhs: &IVec2) -> IVec2 {
651        (*self).div(*rhs)
652    }
653}
654
655impl Div<IVec2> for &IVec2 {
656    type Output = IVec2;
657    #[inline]
658    fn div(self, rhs: IVec2) -> IVec2 {
659        (*self).div(rhs)
660    }
661}
662
663impl DivAssign<IVec2> for IVec2 {
664    #[inline]
665    fn div_assign(&mut self, rhs: Self) {
666        self.x.div_assign(rhs.x);
667        self.y.div_assign(rhs.y);
668    }
669}
670
671impl DivAssign<&Self> for IVec2 {
672    #[inline]
673    fn div_assign(&mut self, rhs: &Self) {
674        self.div_assign(*rhs)
675    }
676}
677
678impl Div<i32> for IVec2 {
679    type Output = Self;
680    #[inline]
681    fn div(self, rhs: i32) -> Self {
682        Self {
683            x: self.x.div(rhs),
684            y: self.y.div(rhs),
685        }
686    }
687}
688
689impl Div<&i32> for IVec2 {
690    type Output = IVec2;
691    #[inline]
692    fn div(self, rhs: &i32) -> IVec2 {
693        self.div(*rhs)
694    }
695}
696
697impl Div<&i32> for &IVec2 {
698    type Output = IVec2;
699    #[inline]
700    fn div(self, rhs: &i32) -> IVec2 {
701        (*self).div(*rhs)
702    }
703}
704
705impl Div<i32> for &IVec2 {
706    type Output = IVec2;
707    #[inline]
708    fn div(self, rhs: i32) -> IVec2 {
709        (*self).div(rhs)
710    }
711}
712
713impl DivAssign<i32> for IVec2 {
714    #[inline]
715    fn div_assign(&mut self, rhs: i32) {
716        self.x.div_assign(rhs);
717        self.y.div_assign(rhs);
718    }
719}
720
721impl DivAssign<&i32> for IVec2 {
722    #[inline]
723    fn div_assign(&mut self, rhs: &i32) {
724        self.div_assign(*rhs)
725    }
726}
727
728impl Div<IVec2> for i32 {
729    type Output = IVec2;
730    #[inline]
731    fn div(self, rhs: IVec2) -> IVec2 {
732        IVec2 {
733            x: self.div(rhs.x),
734            y: self.div(rhs.y),
735        }
736    }
737}
738
739impl Div<&IVec2> for i32 {
740    type Output = IVec2;
741    #[inline]
742    fn div(self, rhs: &IVec2) -> IVec2 {
743        self.div(*rhs)
744    }
745}
746
747impl Div<&IVec2> for &i32 {
748    type Output = IVec2;
749    #[inline]
750    fn div(self, rhs: &IVec2) -> IVec2 {
751        (*self).div(*rhs)
752    }
753}
754
755impl Div<IVec2> for &i32 {
756    type Output = IVec2;
757    #[inline]
758    fn div(self, rhs: IVec2) -> IVec2 {
759        (*self).div(rhs)
760    }
761}
762
763impl Mul<IVec2> for IVec2 {
764    type Output = Self;
765    #[inline]
766    fn mul(self, rhs: Self) -> Self {
767        Self {
768            x: self.x.mul(rhs.x),
769            y: self.y.mul(rhs.y),
770        }
771    }
772}
773
774impl Mul<&IVec2> for IVec2 {
775    type Output = IVec2;
776    #[inline]
777    fn mul(self, rhs: &IVec2) -> IVec2 {
778        self.mul(*rhs)
779    }
780}
781
782impl Mul<&IVec2> for &IVec2 {
783    type Output = IVec2;
784    #[inline]
785    fn mul(self, rhs: &IVec2) -> IVec2 {
786        (*self).mul(*rhs)
787    }
788}
789
790impl Mul<IVec2> for &IVec2 {
791    type Output = IVec2;
792    #[inline]
793    fn mul(self, rhs: IVec2) -> IVec2 {
794        (*self).mul(rhs)
795    }
796}
797
798impl MulAssign<IVec2> for IVec2 {
799    #[inline]
800    fn mul_assign(&mut self, rhs: Self) {
801        self.x.mul_assign(rhs.x);
802        self.y.mul_assign(rhs.y);
803    }
804}
805
806impl MulAssign<&Self> for IVec2 {
807    #[inline]
808    fn mul_assign(&mut self, rhs: &Self) {
809        self.mul_assign(*rhs)
810    }
811}
812
813impl Mul<i32> for IVec2 {
814    type Output = Self;
815    #[inline]
816    fn mul(self, rhs: i32) -> Self {
817        Self {
818            x: self.x.mul(rhs),
819            y: self.y.mul(rhs),
820        }
821    }
822}
823
824impl Mul<&i32> for IVec2 {
825    type Output = IVec2;
826    #[inline]
827    fn mul(self, rhs: &i32) -> IVec2 {
828        self.mul(*rhs)
829    }
830}
831
832impl Mul<&i32> for &IVec2 {
833    type Output = IVec2;
834    #[inline]
835    fn mul(self, rhs: &i32) -> IVec2 {
836        (*self).mul(*rhs)
837    }
838}
839
840impl Mul<i32> for &IVec2 {
841    type Output = IVec2;
842    #[inline]
843    fn mul(self, rhs: i32) -> IVec2 {
844        (*self).mul(rhs)
845    }
846}
847
848impl MulAssign<i32> for IVec2 {
849    #[inline]
850    fn mul_assign(&mut self, rhs: i32) {
851        self.x.mul_assign(rhs);
852        self.y.mul_assign(rhs);
853    }
854}
855
856impl MulAssign<&i32> for IVec2 {
857    #[inline]
858    fn mul_assign(&mut self, rhs: &i32) {
859        self.mul_assign(*rhs)
860    }
861}
862
863impl Mul<IVec2> for i32 {
864    type Output = IVec2;
865    #[inline]
866    fn mul(self, rhs: IVec2) -> IVec2 {
867        IVec2 {
868            x: self.mul(rhs.x),
869            y: self.mul(rhs.y),
870        }
871    }
872}
873
874impl Mul<&IVec2> for i32 {
875    type Output = IVec2;
876    #[inline]
877    fn mul(self, rhs: &IVec2) -> IVec2 {
878        self.mul(*rhs)
879    }
880}
881
882impl Mul<&IVec2> for &i32 {
883    type Output = IVec2;
884    #[inline]
885    fn mul(self, rhs: &IVec2) -> IVec2 {
886        (*self).mul(*rhs)
887    }
888}
889
890impl Mul<IVec2> for &i32 {
891    type Output = IVec2;
892    #[inline]
893    fn mul(self, rhs: IVec2) -> IVec2 {
894        (*self).mul(rhs)
895    }
896}
897
898impl Add<IVec2> for IVec2 {
899    type Output = Self;
900    #[inline]
901    fn add(self, rhs: Self) -> Self {
902        Self {
903            x: self.x.add(rhs.x),
904            y: self.y.add(rhs.y),
905        }
906    }
907}
908
909impl Add<&IVec2> for IVec2 {
910    type Output = IVec2;
911    #[inline]
912    fn add(self, rhs: &IVec2) -> IVec2 {
913        self.add(*rhs)
914    }
915}
916
917impl Add<&IVec2> for &IVec2 {
918    type Output = IVec2;
919    #[inline]
920    fn add(self, rhs: &IVec2) -> IVec2 {
921        (*self).add(*rhs)
922    }
923}
924
925impl Add<IVec2> for &IVec2 {
926    type Output = IVec2;
927    #[inline]
928    fn add(self, rhs: IVec2) -> IVec2 {
929        (*self).add(rhs)
930    }
931}
932
933impl AddAssign<IVec2> for IVec2 {
934    #[inline]
935    fn add_assign(&mut self, rhs: Self) {
936        self.x.add_assign(rhs.x);
937        self.y.add_assign(rhs.y);
938    }
939}
940
941impl AddAssign<&Self> for IVec2 {
942    #[inline]
943    fn add_assign(&mut self, rhs: &Self) {
944        self.add_assign(*rhs)
945    }
946}
947
948impl Add<i32> for IVec2 {
949    type Output = Self;
950    #[inline]
951    fn add(self, rhs: i32) -> Self {
952        Self {
953            x: self.x.add(rhs),
954            y: self.y.add(rhs),
955        }
956    }
957}
958
959impl Add<&i32> for IVec2 {
960    type Output = IVec2;
961    #[inline]
962    fn add(self, rhs: &i32) -> IVec2 {
963        self.add(*rhs)
964    }
965}
966
967impl Add<&i32> for &IVec2 {
968    type Output = IVec2;
969    #[inline]
970    fn add(self, rhs: &i32) -> IVec2 {
971        (*self).add(*rhs)
972    }
973}
974
975impl Add<i32> for &IVec2 {
976    type Output = IVec2;
977    #[inline]
978    fn add(self, rhs: i32) -> IVec2 {
979        (*self).add(rhs)
980    }
981}
982
983impl AddAssign<i32> for IVec2 {
984    #[inline]
985    fn add_assign(&mut self, rhs: i32) {
986        self.x.add_assign(rhs);
987        self.y.add_assign(rhs);
988    }
989}
990
991impl AddAssign<&i32> for IVec2 {
992    #[inline]
993    fn add_assign(&mut self, rhs: &i32) {
994        self.add_assign(*rhs)
995    }
996}
997
998impl Add<IVec2> for i32 {
999    type Output = IVec2;
1000    #[inline]
1001    fn add(self, rhs: IVec2) -> IVec2 {
1002        IVec2 {
1003            x: self.add(rhs.x),
1004            y: self.add(rhs.y),
1005        }
1006    }
1007}
1008
1009impl Add<&IVec2> for i32 {
1010    type Output = IVec2;
1011    #[inline]
1012    fn add(self, rhs: &IVec2) -> IVec2 {
1013        self.add(*rhs)
1014    }
1015}
1016
1017impl Add<&IVec2> for &i32 {
1018    type Output = IVec2;
1019    #[inline]
1020    fn add(self, rhs: &IVec2) -> IVec2 {
1021        (*self).add(*rhs)
1022    }
1023}
1024
1025impl Add<IVec2> for &i32 {
1026    type Output = IVec2;
1027    #[inline]
1028    fn add(self, rhs: IVec2) -> IVec2 {
1029        (*self).add(rhs)
1030    }
1031}
1032
1033impl Sub<IVec2> for IVec2 {
1034    type Output = Self;
1035    #[inline]
1036    fn sub(self, rhs: Self) -> Self {
1037        Self {
1038            x: self.x.sub(rhs.x),
1039            y: self.y.sub(rhs.y),
1040        }
1041    }
1042}
1043
1044impl Sub<&IVec2> for IVec2 {
1045    type Output = IVec2;
1046    #[inline]
1047    fn sub(self, rhs: &IVec2) -> IVec2 {
1048        self.sub(*rhs)
1049    }
1050}
1051
1052impl Sub<&IVec2> for &IVec2 {
1053    type Output = IVec2;
1054    #[inline]
1055    fn sub(self, rhs: &IVec2) -> IVec2 {
1056        (*self).sub(*rhs)
1057    }
1058}
1059
1060impl Sub<IVec2> for &IVec2 {
1061    type Output = IVec2;
1062    #[inline]
1063    fn sub(self, rhs: IVec2) -> IVec2 {
1064        (*self).sub(rhs)
1065    }
1066}
1067
1068impl SubAssign<IVec2> for IVec2 {
1069    #[inline]
1070    fn sub_assign(&mut self, rhs: IVec2) {
1071        self.x.sub_assign(rhs.x);
1072        self.y.sub_assign(rhs.y);
1073    }
1074}
1075
1076impl SubAssign<&Self> for IVec2 {
1077    #[inline]
1078    fn sub_assign(&mut self, rhs: &Self) {
1079        self.sub_assign(*rhs)
1080    }
1081}
1082
1083impl Sub<i32> for IVec2 {
1084    type Output = Self;
1085    #[inline]
1086    fn sub(self, rhs: i32) -> Self {
1087        Self {
1088            x: self.x.sub(rhs),
1089            y: self.y.sub(rhs),
1090        }
1091    }
1092}
1093
1094impl Sub<&i32> for IVec2 {
1095    type Output = IVec2;
1096    #[inline]
1097    fn sub(self, rhs: &i32) -> IVec2 {
1098        self.sub(*rhs)
1099    }
1100}
1101
1102impl Sub<&i32> for &IVec2 {
1103    type Output = IVec2;
1104    #[inline]
1105    fn sub(self, rhs: &i32) -> IVec2 {
1106        (*self).sub(*rhs)
1107    }
1108}
1109
1110impl Sub<i32> for &IVec2 {
1111    type Output = IVec2;
1112    #[inline]
1113    fn sub(self, rhs: i32) -> IVec2 {
1114        (*self).sub(rhs)
1115    }
1116}
1117
1118impl SubAssign<i32> for IVec2 {
1119    #[inline]
1120    fn sub_assign(&mut self, rhs: i32) {
1121        self.x.sub_assign(rhs);
1122        self.y.sub_assign(rhs);
1123    }
1124}
1125
1126impl SubAssign<&i32> for IVec2 {
1127    #[inline]
1128    fn sub_assign(&mut self, rhs: &i32) {
1129        self.sub_assign(*rhs)
1130    }
1131}
1132
1133impl Sub<IVec2> for i32 {
1134    type Output = IVec2;
1135    #[inline]
1136    fn sub(self, rhs: IVec2) -> IVec2 {
1137        IVec2 {
1138            x: self.sub(rhs.x),
1139            y: self.sub(rhs.y),
1140        }
1141    }
1142}
1143
1144impl Sub<&IVec2> for i32 {
1145    type Output = IVec2;
1146    #[inline]
1147    fn sub(self, rhs: &IVec2) -> IVec2 {
1148        self.sub(*rhs)
1149    }
1150}
1151
1152impl Sub<&IVec2> for &i32 {
1153    type Output = IVec2;
1154    #[inline]
1155    fn sub(self, rhs: &IVec2) -> IVec2 {
1156        (*self).sub(*rhs)
1157    }
1158}
1159
1160impl Sub<IVec2> for &i32 {
1161    type Output = IVec2;
1162    #[inline]
1163    fn sub(self, rhs: IVec2) -> IVec2 {
1164        (*self).sub(rhs)
1165    }
1166}
1167
1168impl Rem<IVec2> for IVec2 {
1169    type Output = Self;
1170    #[inline]
1171    fn rem(self, rhs: Self) -> Self {
1172        Self {
1173            x: self.x.rem(rhs.x),
1174            y: self.y.rem(rhs.y),
1175        }
1176    }
1177}
1178
1179impl Rem<&IVec2> for IVec2 {
1180    type Output = IVec2;
1181    #[inline]
1182    fn rem(self, rhs: &IVec2) -> IVec2 {
1183        self.rem(*rhs)
1184    }
1185}
1186
1187impl Rem<&IVec2> for &IVec2 {
1188    type Output = IVec2;
1189    #[inline]
1190    fn rem(self, rhs: &IVec2) -> IVec2 {
1191        (*self).rem(*rhs)
1192    }
1193}
1194
1195impl Rem<IVec2> for &IVec2 {
1196    type Output = IVec2;
1197    #[inline]
1198    fn rem(self, rhs: IVec2) -> IVec2 {
1199        (*self).rem(rhs)
1200    }
1201}
1202
1203impl RemAssign<IVec2> for IVec2 {
1204    #[inline]
1205    fn rem_assign(&mut self, rhs: Self) {
1206        self.x.rem_assign(rhs.x);
1207        self.y.rem_assign(rhs.y);
1208    }
1209}
1210
1211impl RemAssign<&Self> for IVec2 {
1212    #[inline]
1213    fn rem_assign(&mut self, rhs: &Self) {
1214        self.rem_assign(*rhs)
1215    }
1216}
1217
1218impl Rem<i32> for IVec2 {
1219    type Output = Self;
1220    #[inline]
1221    fn rem(self, rhs: i32) -> Self {
1222        Self {
1223            x: self.x.rem(rhs),
1224            y: self.y.rem(rhs),
1225        }
1226    }
1227}
1228
1229impl Rem<&i32> for IVec2 {
1230    type Output = IVec2;
1231    #[inline]
1232    fn rem(self, rhs: &i32) -> IVec2 {
1233        self.rem(*rhs)
1234    }
1235}
1236
1237impl Rem<&i32> for &IVec2 {
1238    type Output = IVec2;
1239    #[inline]
1240    fn rem(self, rhs: &i32) -> IVec2 {
1241        (*self).rem(*rhs)
1242    }
1243}
1244
1245impl Rem<i32> for &IVec2 {
1246    type Output = IVec2;
1247    #[inline]
1248    fn rem(self, rhs: i32) -> IVec2 {
1249        (*self).rem(rhs)
1250    }
1251}
1252
1253impl RemAssign<i32> for IVec2 {
1254    #[inline]
1255    fn rem_assign(&mut self, rhs: i32) {
1256        self.x.rem_assign(rhs);
1257        self.y.rem_assign(rhs);
1258    }
1259}
1260
1261impl RemAssign<&i32> for IVec2 {
1262    #[inline]
1263    fn rem_assign(&mut self, rhs: &i32) {
1264        self.rem_assign(*rhs)
1265    }
1266}
1267
1268impl Rem<IVec2> for i32 {
1269    type Output = IVec2;
1270    #[inline]
1271    fn rem(self, rhs: IVec2) -> IVec2 {
1272        IVec2 {
1273            x: self.rem(rhs.x),
1274            y: self.rem(rhs.y),
1275        }
1276    }
1277}
1278
1279impl Rem<&IVec2> for i32 {
1280    type Output = IVec2;
1281    #[inline]
1282    fn rem(self, rhs: &IVec2) -> IVec2 {
1283        self.rem(*rhs)
1284    }
1285}
1286
1287impl Rem<&IVec2> for &i32 {
1288    type Output = IVec2;
1289    #[inline]
1290    fn rem(self, rhs: &IVec2) -> IVec2 {
1291        (*self).rem(*rhs)
1292    }
1293}
1294
1295impl Rem<IVec2> for &i32 {
1296    type Output = IVec2;
1297    #[inline]
1298    fn rem(self, rhs: IVec2) -> IVec2 {
1299        (*self).rem(rhs)
1300    }
1301}
1302
1303#[cfg(not(target_arch = "spirv"))]
1304impl AsRef<[i32; 2]> for IVec2 {
1305    #[inline]
1306    fn as_ref(&self) -> &[i32; 2] {
1307        unsafe { &*(self as *const IVec2 as *const [i32; 2]) }
1308    }
1309}
1310
1311#[cfg(not(target_arch = "spirv"))]
1312impl AsMut<[i32; 2]> for IVec2 {
1313    #[inline]
1314    fn as_mut(&mut self) -> &mut [i32; 2] {
1315        unsafe { &mut *(self as *mut IVec2 as *mut [i32; 2]) }
1316    }
1317}
1318
1319impl Sum for IVec2 {
1320    #[inline]
1321    fn sum<I>(iter: I) -> Self
1322    where
1323        I: Iterator<Item = Self>,
1324    {
1325        iter.fold(Self::ZERO, Self::add)
1326    }
1327}
1328
1329impl<'a> Sum<&'a Self> for IVec2 {
1330    #[inline]
1331    fn sum<I>(iter: I) -> Self
1332    where
1333        I: Iterator<Item = &'a Self>,
1334    {
1335        iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1336    }
1337}
1338
1339impl Product for IVec2 {
1340    #[inline]
1341    fn product<I>(iter: I) -> Self
1342    where
1343        I: Iterator<Item = Self>,
1344    {
1345        iter.fold(Self::ONE, Self::mul)
1346    }
1347}
1348
1349impl<'a> Product<&'a Self> for IVec2 {
1350    #[inline]
1351    fn product<I>(iter: I) -> Self
1352    where
1353        I: Iterator<Item = &'a Self>,
1354    {
1355        iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1356    }
1357}
1358
1359impl Neg for IVec2 {
1360    type Output = Self;
1361    #[inline]
1362    fn neg(self) -> Self {
1363        Self {
1364            x: self.x.neg(),
1365            y: self.y.neg(),
1366        }
1367    }
1368}
1369
1370impl Neg for &IVec2 {
1371    type Output = IVec2;
1372    #[inline]
1373    fn neg(self) -> IVec2 {
1374        (*self).neg()
1375    }
1376}
1377
1378impl Not for IVec2 {
1379    type Output = Self;
1380    #[inline]
1381    fn not(self) -> Self::Output {
1382        Self {
1383            x: self.x.not(),
1384            y: self.y.not(),
1385        }
1386    }
1387}
1388
1389impl BitAnd for IVec2 {
1390    type Output = Self;
1391    #[inline]
1392    fn bitand(self, rhs: Self) -> Self::Output {
1393        Self {
1394            x: self.x.bitand(rhs.x),
1395            y: self.y.bitand(rhs.y),
1396        }
1397    }
1398}
1399
1400impl BitOr for IVec2 {
1401    type Output = Self;
1402    #[inline]
1403    fn bitor(self, rhs: Self) -> Self::Output {
1404        Self {
1405            x: self.x.bitor(rhs.x),
1406            y: self.y.bitor(rhs.y),
1407        }
1408    }
1409}
1410
1411impl BitXor for IVec2 {
1412    type Output = Self;
1413    #[inline]
1414    fn bitxor(self, rhs: Self) -> Self::Output {
1415        Self {
1416            x: self.x.bitxor(rhs.x),
1417            y: self.y.bitxor(rhs.y),
1418        }
1419    }
1420}
1421
1422impl BitAnd<i32> for IVec2 {
1423    type Output = Self;
1424    #[inline]
1425    fn bitand(self, rhs: i32) -> Self::Output {
1426        Self {
1427            x: self.x.bitand(rhs),
1428            y: self.y.bitand(rhs),
1429        }
1430    }
1431}
1432
1433impl BitOr<i32> for IVec2 {
1434    type Output = Self;
1435    #[inline]
1436    fn bitor(self, rhs: i32) -> Self::Output {
1437        Self {
1438            x: self.x.bitor(rhs),
1439            y: self.y.bitor(rhs),
1440        }
1441    }
1442}
1443
1444impl BitXor<i32> for IVec2 {
1445    type Output = Self;
1446    #[inline]
1447    fn bitxor(self, rhs: i32) -> Self::Output {
1448        Self {
1449            x: self.x.bitxor(rhs),
1450            y: self.y.bitxor(rhs),
1451        }
1452    }
1453}
1454
1455impl Shl<i8> for IVec2 {
1456    type Output = Self;
1457    #[inline]
1458    fn shl(self, rhs: i8) -> Self::Output {
1459        Self {
1460            x: self.x.shl(rhs),
1461            y: self.y.shl(rhs),
1462        }
1463    }
1464}
1465
1466impl Shr<i8> for IVec2 {
1467    type Output = Self;
1468    #[inline]
1469    fn shr(self, rhs: i8) -> Self::Output {
1470        Self {
1471            x: self.x.shr(rhs),
1472            y: self.y.shr(rhs),
1473        }
1474    }
1475}
1476
1477impl Shl<i16> for IVec2 {
1478    type Output = Self;
1479    #[inline]
1480    fn shl(self, rhs: i16) -> Self::Output {
1481        Self {
1482            x: self.x.shl(rhs),
1483            y: self.y.shl(rhs),
1484        }
1485    }
1486}
1487
1488impl Shr<i16> for IVec2 {
1489    type Output = Self;
1490    #[inline]
1491    fn shr(self, rhs: i16) -> Self::Output {
1492        Self {
1493            x: self.x.shr(rhs),
1494            y: self.y.shr(rhs),
1495        }
1496    }
1497}
1498
1499impl Shl<i32> for IVec2 {
1500    type Output = Self;
1501    #[inline]
1502    fn shl(self, rhs: i32) -> Self::Output {
1503        Self {
1504            x: self.x.shl(rhs),
1505            y: self.y.shl(rhs),
1506        }
1507    }
1508}
1509
1510impl Shr<i32> for IVec2 {
1511    type Output = Self;
1512    #[inline]
1513    fn shr(self, rhs: i32) -> Self::Output {
1514        Self {
1515            x: self.x.shr(rhs),
1516            y: self.y.shr(rhs),
1517        }
1518    }
1519}
1520
1521impl Shl<i64> for IVec2 {
1522    type Output = Self;
1523    #[inline]
1524    fn shl(self, rhs: i64) -> Self::Output {
1525        Self {
1526            x: self.x.shl(rhs),
1527            y: self.y.shl(rhs),
1528        }
1529    }
1530}
1531
1532impl Shr<i64> for IVec2 {
1533    type Output = Self;
1534    #[inline]
1535    fn shr(self, rhs: i64) -> Self::Output {
1536        Self {
1537            x: self.x.shr(rhs),
1538            y: self.y.shr(rhs),
1539        }
1540    }
1541}
1542
1543impl Shl<u8> for IVec2 {
1544    type Output = Self;
1545    #[inline]
1546    fn shl(self, rhs: u8) -> Self::Output {
1547        Self {
1548            x: self.x.shl(rhs),
1549            y: self.y.shl(rhs),
1550        }
1551    }
1552}
1553
1554impl Shr<u8> for IVec2 {
1555    type Output = Self;
1556    #[inline]
1557    fn shr(self, rhs: u8) -> Self::Output {
1558        Self {
1559            x: self.x.shr(rhs),
1560            y: self.y.shr(rhs),
1561        }
1562    }
1563}
1564
1565impl Shl<u16> for IVec2 {
1566    type Output = Self;
1567    #[inline]
1568    fn shl(self, rhs: u16) -> Self::Output {
1569        Self {
1570            x: self.x.shl(rhs),
1571            y: self.y.shl(rhs),
1572        }
1573    }
1574}
1575
1576impl Shr<u16> for IVec2 {
1577    type Output = Self;
1578    #[inline]
1579    fn shr(self, rhs: u16) -> Self::Output {
1580        Self {
1581            x: self.x.shr(rhs),
1582            y: self.y.shr(rhs),
1583        }
1584    }
1585}
1586
1587impl Shl<u32> for IVec2 {
1588    type Output = Self;
1589    #[inline]
1590    fn shl(self, rhs: u32) -> Self::Output {
1591        Self {
1592            x: self.x.shl(rhs),
1593            y: self.y.shl(rhs),
1594        }
1595    }
1596}
1597
1598impl Shr<u32> for IVec2 {
1599    type Output = Self;
1600    #[inline]
1601    fn shr(self, rhs: u32) -> Self::Output {
1602        Self {
1603            x: self.x.shr(rhs),
1604            y: self.y.shr(rhs),
1605        }
1606    }
1607}
1608
1609impl Shl<u64> for IVec2 {
1610    type Output = Self;
1611    #[inline]
1612    fn shl(self, rhs: u64) -> Self::Output {
1613        Self {
1614            x: self.x.shl(rhs),
1615            y: self.y.shl(rhs),
1616        }
1617    }
1618}
1619
1620impl Shr<u64> for IVec2 {
1621    type Output = Self;
1622    #[inline]
1623    fn shr(self, rhs: u64) -> Self::Output {
1624        Self {
1625            x: self.x.shr(rhs),
1626            y: self.y.shr(rhs),
1627        }
1628    }
1629}
1630
1631impl Shl<crate::IVec2> for IVec2 {
1632    type Output = Self;
1633    #[inline]
1634    fn shl(self, rhs: crate::IVec2) -> Self::Output {
1635        Self {
1636            x: self.x.shl(rhs.x),
1637            y: self.y.shl(rhs.y),
1638        }
1639    }
1640}
1641
1642impl Shr<crate::IVec2> for IVec2 {
1643    type Output = Self;
1644    #[inline]
1645    fn shr(self, rhs: crate::IVec2) -> Self::Output {
1646        Self {
1647            x: self.x.shr(rhs.x),
1648            y: self.y.shr(rhs.y),
1649        }
1650    }
1651}
1652
1653impl Shl<crate::UVec2> for IVec2 {
1654    type Output = Self;
1655    #[inline]
1656    fn shl(self, rhs: crate::UVec2) -> Self::Output {
1657        Self {
1658            x: self.x.shl(rhs.x),
1659            y: self.y.shl(rhs.y),
1660        }
1661    }
1662}
1663
1664impl Shr<crate::UVec2> for IVec2 {
1665    type Output = Self;
1666    #[inline]
1667    fn shr(self, rhs: crate::UVec2) -> Self::Output {
1668        Self {
1669            x: self.x.shr(rhs.x),
1670            y: self.y.shr(rhs.y),
1671        }
1672    }
1673}
1674
1675impl Index<usize> for IVec2 {
1676    type Output = i32;
1677    #[inline]
1678    fn index(&self, index: usize) -> &Self::Output {
1679        match index {
1680            0 => &self.x,
1681            1 => &self.y,
1682            _ => panic!("index out of bounds"),
1683        }
1684    }
1685}
1686
1687impl IndexMut<usize> for IVec2 {
1688    #[inline]
1689    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1690        match index {
1691            0 => &mut self.x,
1692            1 => &mut self.y,
1693            _ => panic!("index out of bounds"),
1694        }
1695    }
1696}
1697
1698impl fmt::Display for IVec2 {
1699    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1700        write!(f, "[{}, {}]", self.x, self.y)
1701    }
1702}
1703
1704impl fmt::Debug for IVec2 {
1705    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1706        fmt.debug_tuple(stringify!(IVec2))
1707            .field(&self.x)
1708            .field(&self.y)
1709            .finish()
1710    }
1711}
1712
1713impl From<[i32; 2]> for IVec2 {
1714    #[inline]
1715    fn from(a: [i32; 2]) -> Self {
1716        Self::new(a[0], a[1])
1717    }
1718}
1719
1720impl From<IVec2> for [i32; 2] {
1721    #[inline]
1722    fn from(v: IVec2) -> Self {
1723        [v.x, v.y]
1724    }
1725}
1726
1727impl From<(i32, i32)> for IVec2 {
1728    #[inline]
1729    fn from(t: (i32, i32)) -> Self {
1730        Self::new(t.0, t.1)
1731    }
1732}
1733
1734impl From<IVec2> for (i32, i32) {
1735    #[inline]
1736    fn from(v: IVec2) -> Self {
1737        (v.x, v.y)
1738    }
1739}
1740
1741impl From<I8Vec2> for IVec2 {
1742    #[inline]
1743    fn from(v: I8Vec2) -> Self {
1744        Self::new(i32::from(v.x), i32::from(v.y))
1745    }
1746}
1747
1748impl From<U8Vec2> for IVec2 {
1749    #[inline]
1750    fn from(v: U8Vec2) -> Self {
1751        Self::new(i32::from(v.x), i32::from(v.y))
1752    }
1753}
1754
1755impl From<I16Vec2> for IVec2 {
1756    #[inline]
1757    fn from(v: I16Vec2) -> Self {
1758        Self::new(i32::from(v.x), i32::from(v.y))
1759    }
1760}
1761
1762impl From<U16Vec2> for IVec2 {
1763    #[inline]
1764    fn from(v: U16Vec2) -> Self {
1765        Self::new(i32::from(v.x), i32::from(v.y))
1766    }
1767}
1768
1769impl TryFrom<UVec2> for IVec2 {
1770    type Error = core::num::TryFromIntError;
1771
1772    #[inline]
1773    fn try_from(v: UVec2) -> Result<Self, Self::Error> {
1774        Ok(Self::new(i32::try_from(v.x)?, i32::try_from(v.y)?))
1775    }
1776}
1777
1778impl TryFrom<I64Vec2> for IVec2 {
1779    type Error = core::num::TryFromIntError;
1780
1781    #[inline]
1782    fn try_from(v: I64Vec2) -> Result<Self, Self::Error> {
1783        Ok(Self::new(i32::try_from(v.x)?, i32::try_from(v.y)?))
1784    }
1785}
1786
1787impl TryFrom<U64Vec2> for IVec2 {
1788    type Error = core::num::TryFromIntError;
1789
1790    #[inline]
1791    fn try_from(v: U64Vec2) -> Result<Self, Self::Error> {
1792        Ok(Self::new(i32::try_from(v.x)?, i32::try_from(v.y)?))
1793    }
1794}
1795
1796impl From<BVec2> for IVec2 {
1797    #[inline]
1798    fn from(v: BVec2) -> Self {
1799        Self::new(i32::from(v.x), i32::from(v.y))
1800    }
1801}