glam/i64/
i64vec2.rs

1// Generated from vec.rs.tera template. Edit the template, not the generated file.
2
3use crate::{BVec2, I16Vec2, I64Vec3, I8Vec2, IVec2, 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 i64vec2(x: i64, y: i64) -> I64Vec2 {
13    I64Vec2::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(16)))]
20#[cfg_attr(not(target_arch = "spirv"), repr(C))]
21#[cfg_attr(target_arch = "spirv", repr(simd))]
22pub struct I64Vec2 {
23    pub x: i64,
24    pub y: i64,
25}
26
27impl I64Vec2 {
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 `i64::MIN`.
38    pub const MIN: Self = Self::splat(i64::MIN);
39
40    /// All `i64::MAX`.
41    pub const MAX: Self = Self::splat(i64::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: i64, y: i64) -> 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: i64) -> 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(i64) -> i64,
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: [i64; 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) -> [i64; 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: &[i64]) -> 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 [i64]) {
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: i64) -> I64Vec3 {
136        I64Vec3::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: i64) -> 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: i64) -> 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) -> i64 {
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 [`i64::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) -> i64 {
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) -> i64 {
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) -> i64 {
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) -> i64 {
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) -> i64 {
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) -> i64 {
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]: i64::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    /// Computes the [manhattan distance] between two points.
381    ///
382    /// # Overflow
383    /// This method may overflow if the result is greater than [`u64::MAX`].
384    ///
385    /// See also [`checked_manhattan_distance`][I64Vec2::checked_manhattan_distance].
386    ///
387    /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
388    #[inline]
389    #[must_use]
390    pub fn manhattan_distance(self, other: Self) -> u64 {
391        self.x.abs_diff(other.x) + self.y.abs_diff(other.y)
392    }
393
394    /// Computes the [manhattan distance] between two points.
395    ///
396    /// This will returns [`None`] if the result is greater than [`u64::MAX`].
397    ///
398    /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
399    #[inline]
400    #[must_use]
401    pub fn checked_manhattan_distance(self, other: Self) -> Option<u64> {
402        let d = self.x.abs_diff(other.x);
403        d.checked_add(self.y.abs_diff(other.y))
404    }
405
406    /// Computes the [chebyshev distance] between two points.
407    ///
408    /// [chebyshev distance]: https://en.wikipedia.org/wiki/Chebyshev_distance
409    #[inline]
410    #[must_use]
411    pub fn chebyshev_distance(self, other: Self) -> u64 {
412        // Note: the compiler will eventually optimize out the loop
413        [self.x.abs_diff(other.x), self.y.abs_diff(other.y)]
414            .into_iter()
415            .max()
416            .unwrap()
417    }
418
419    /// Returns a vector that is equal to `self` rotated by 90 degrees.
420    #[inline]
421    #[must_use]
422    pub fn perp(self) -> Self {
423        Self {
424            x: -self.y,
425            y: self.x,
426        }
427    }
428
429    /// The perpendicular dot product of `self` and `rhs`.
430    /// Also known as the wedge product, 2D cross product, and determinant.
431    #[doc(alias = "wedge")]
432    #[doc(alias = "cross")]
433    #[doc(alias = "determinant")]
434    #[inline]
435    #[must_use]
436    pub fn perp_dot(self, rhs: Self) -> i64 {
437        (self.x * rhs.y) - (self.y * rhs.x)
438    }
439
440    /// Returns `rhs` rotated by the angle of `self`. If `self` is normalized,
441    /// then this just rotation. This is what you usually want. Otherwise,
442    /// it will be like a rotation with a multiplication by `self`'s length.
443    #[inline]
444    #[must_use]
445    pub fn rotate(self, rhs: Self) -> Self {
446        Self {
447            x: self.x * rhs.x - self.y * rhs.y,
448            y: self.y * rhs.x + self.x * rhs.y,
449        }
450    }
451
452    /// Casts all elements of `self` to `f32`.
453    #[inline]
454    #[must_use]
455    pub fn as_vec2(&self) -> crate::Vec2 {
456        crate::Vec2::new(self.x as f32, self.y as f32)
457    }
458
459    /// Casts all elements of `self` to `f64`.
460    #[inline]
461    #[must_use]
462    pub fn as_dvec2(&self) -> crate::DVec2 {
463        crate::DVec2::new(self.x as f64, self.y as f64)
464    }
465
466    /// Casts all elements of `self` to `i8`.
467    #[inline]
468    #[must_use]
469    pub fn as_i8vec2(&self) -> crate::I8Vec2 {
470        crate::I8Vec2::new(self.x as i8, self.y as i8)
471    }
472
473    /// Casts all elements of `self` to `u8`.
474    #[inline]
475    #[must_use]
476    pub fn as_u8vec2(&self) -> crate::U8Vec2 {
477        crate::U8Vec2::new(self.x as u8, self.y as u8)
478    }
479
480    /// Casts all elements of `self` to `i16`.
481    #[inline]
482    #[must_use]
483    pub fn as_i16vec2(&self) -> crate::I16Vec2 {
484        crate::I16Vec2::new(self.x as i16, self.y as i16)
485    }
486
487    /// Casts all elements of `self` to `u16`.
488    #[inline]
489    #[must_use]
490    pub fn as_u16vec2(&self) -> crate::U16Vec2 {
491        crate::U16Vec2::new(self.x as u16, self.y as u16)
492    }
493
494    /// Casts all elements of `self` to `i32`.
495    #[inline]
496    #[must_use]
497    pub fn as_ivec2(&self) -> crate::IVec2 {
498        crate::IVec2::new(self.x as i32, self.y as i32)
499    }
500
501    /// Casts all elements of `self` to `u32`.
502    #[inline]
503    #[must_use]
504    pub fn as_uvec2(&self) -> crate::UVec2 {
505        crate::UVec2::new(self.x as u32, self.y as u32)
506    }
507
508    /// Casts all elements of `self` to `u64`.
509    #[inline]
510    #[must_use]
511    pub fn as_u64vec2(&self) -> crate::U64Vec2 {
512        crate::U64Vec2::new(self.x as u64, self.y as u64)
513    }
514
515    /// Returns a vector containing the wrapping addition of `self` and `rhs`.
516    ///
517    /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
518    #[inline]
519    #[must_use]
520    pub const fn checked_add(self, rhs: Self) -> Option<Self> {
521        let x = match self.x.checked_add(rhs.x) {
522            Some(v) => v,
523            None => return None,
524        };
525        let y = match self.y.checked_add(rhs.y) {
526            Some(v) => v,
527            None => return None,
528        };
529
530        Some(Self { x, y })
531    }
532
533    /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
534    ///
535    /// In other words this computes `Some([self.x - rhs.x, self.y - rhs.y, ..])` but returns `None` on any overflow.
536    #[inline]
537    #[must_use]
538    pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
539        let x = match self.x.checked_sub(rhs.x) {
540            Some(v) => v,
541            None => return None,
542        };
543        let y = match self.y.checked_sub(rhs.y) {
544            Some(v) => v,
545            None => return None,
546        };
547
548        Some(Self { x, y })
549    }
550
551    /// Returns a vector containing the wrapping multiplication 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_mul(self, rhs: Self) -> Option<Self> {
557        let x = match self.x.checked_mul(rhs.x) {
558            Some(v) => v,
559            None => return None,
560        };
561        let y = match self.y.checked_mul(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 division 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 division by zero.
572    #[inline]
573    #[must_use]
574    pub const fn checked_div(self, rhs: Self) -> Option<Self> {
575        let x = match self.x.checked_div(rhs.x) {
576            Some(v) => v,
577            None => return None,
578        };
579        let y = match self.y.checked_div(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 addition of `self` and `rhs`.
588    ///
589    /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
590    #[inline]
591    #[must_use]
592    pub const fn wrapping_add(self, rhs: Self) -> Self {
593        Self {
594            x: self.x.wrapping_add(rhs.x),
595            y: self.y.wrapping_add(rhs.y),
596        }
597    }
598
599    /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
600    ///
601    /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
602    #[inline]
603    #[must_use]
604    pub const fn wrapping_sub(self, rhs: Self) -> Self {
605        Self {
606            x: self.x.wrapping_sub(rhs.x),
607            y: self.y.wrapping_sub(rhs.y),
608        }
609    }
610
611    /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
612    ///
613    /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
614    #[inline]
615    #[must_use]
616    pub const fn wrapping_mul(self, rhs: Self) -> Self {
617        Self {
618            x: self.x.wrapping_mul(rhs.x),
619            y: self.y.wrapping_mul(rhs.y),
620        }
621    }
622
623    /// Returns a vector containing the wrapping division of `self` and `rhs`.
624    ///
625    /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
626    #[inline]
627    #[must_use]
628    pub const fn wrapping_div(self, rhs: Self) -> Self {
629        Self {
630            x: self.x.wrapping_div(rhs.x),
631            y: self.y.wrapping_div(rhs.y),
632        }
633    }
634
635    /// Returns a vector containing the saturating addition of `self` and `rhs`.
636    ///
637    /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
638    #[inline]
639    #[must_use]
640    pub const fn saturating_add(self, rhs: Self) -> Self {
641        Self {
642            x: self.x.saturating_add(rhs.x),
643            y: self.y.saturating_add(rhs.y),
644        }
645    }
646
647    /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
648    ///
649    /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
650    #[inline]
651    #[must_use]
652    pub const fn saturating_sub(self, rhs: Self) -> Self {
653        Self {
654            x: self.x.saturating_sub(rhs.x),
655            y: self.y.saturating_sub(rhs.y),
656        }
657    }
658
659    /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
660    ///
661    /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
662    #[inline]
663    #[must_use]
664    pub const fn saturating_mul(self, rhs: Self) -> Self {
665        Self {
666            x: self.x.saturating_mul(rhs.x),
667            y: self.y.saturating_mul(rhs.y),
668        }
669    }
670
671    /// Returns a vector containing the saturating division of `self` and `rhs`.
672    ///
673    /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
674    #[inline]
675    #[must_use]
676    pub const fn saturating_div(self, rhs: Self) -> Self {
677        Self {
678            x: self.x.saturating_div(rhs.x),
679            y: self.y.saturating_div(rhs.y),
680        }
681    }
682
683    /// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`.
684    ///
685    /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
686    #[inline]
687    #[must_use]
688    pub const fn checked_add_unsigned(self, rhs: U64Vec2) -> Option<Self> {
689        let x = match self.x.checked_add_unsigned(rhs.x) {
690            Some(v) => v,
691            None => return None,
692        };
693        let y = match self.y.checked_add_unsigned(rhs.y) {
694            Some(v) => v,
695            None => return None,
696        };
697
698        Some(Self { x, y })
699    }
700
701    /// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`.
702    ///
703    /// In other words this computes `Some([self.x - rhs.x, self.y - rhs.y, ..])` but returns `None` on any overflow.
704    #[inline]
705    #[must_use]
706    pub const fn checked_sub_unsigned(self, rhs: U64Vec2) -> Option<Self> {
707        let x = match self.x.checked_sub_unsigned(rhs.x) {
708            Some(v) => v,
709            None => return None,
710        };
711        let y = match self.y.checked_sub_unsigned(rhs.y) {
712            Some(v) => v,
713            None => return None,
714        };
715
716        Some(Self { x, y })
717    }
718
719    /// Returns a vector containing the wrapping addition of `self` and unsigned vector `rhs`.
720    ///
721    /// In other words this computes `[self.x.wrapping_add_unsigned(rhs.x), self.y.wrapping_add_unsigned(rhs.y), ..]`.
722    #[inline]
723    #[must_use]
724    pub const fn wrapping_add_unsigned(self, rhs: U64Vec2) -> Self {
725        Self {
726            x: self.x.wrapping_add_unsigned(rhs.x),
727            y: self.y.wrapping_add_unsigned(rhs.y),
728        }
729    }
730
731    /// Returns a vector containing the wrapping subtraction of `self` and unsigned vector `rhs`.
732    ///
733    /// In other words this computes `[self.x.wrapping_sub_unsigned(rhs.x), self.y.wrapping_sub_unsigned(rhs.y), ..]`.
734    #[inline]
735    #[must_use]
736    pub const fn wrapping_sub_unsigned(self, rhs: U64Vec2) -> Self {
737        Self {
738            x: self.x.wrapping_sub_unsigned(rhs.x),
739            y: self.y.wrapping_sub_unsigned(rhs.y),
740        }
741    }
742
743    // Returns a vector containing the saturating addition of `self` and unsigned vector `rhs`.
744    ///
745    /// In other words this computes `[self.x.saturating_add_unsigned(rhs.x), self.y.saturating_add_unsigned(rhs.y), ..]`.
746    #[inline]
747    #[must_use]
748    pub const fn saturating_add_unsigned(self, rhs: U64Vec2) -> Self {
749        Self {
750            x: self.x.saturating_add_unsigned(rhs.x),
751            y: self.y.saturating_add_unsigned(rhs.y),
752        }
753    }
754
755    /// Returns a vector containing the saturating subtraction of `self` and unsigned vector `rhs`.
756    ///
757    /// In other words this computes `[self.x.saturating_sub_unsigned(rhs.x), self.y.saturating_sub_unsigned(rhs.y), ..]`.
758    #[inline]
759    #[must_use]
760    pub const fn saturating_sub_unsigned(self, rhs: U64Vec2) -> Self {
761        Self {
762            x: self.x.saturating_sub_unsigned(rhs.x),
763            y: self.y.saturating_sub_unsigned(rhs.y),
764        }
765    }
766}
767
768impl Default for I64Vec2 {
769    #[inline(always)]
770    fn default() -> Self {
771        Self::ZERO
772    }
773}
774
775impl Div<I64Vec2> for I64Vec2 {
776    type Output = Self;
777    #[inline]
778    fn div(self, rhs: Self) -> Self {
779        Self {
780            x: self.x.div(rhs.x),
781            y: self.y.div(rhs.y),
782        }
783    }
784}
785
786impl Div<&I64Vec2> for I64Vec2 {
787    type Output = I64Vec2;
788    #[inline]
789    fn div(self, rhs: &I64Vec2) -> I64Vec2 {
790        self.div(*rhs)
791    }
792}
793
794impl Div<&I64Vec2> for &I64Vec2 {
795    type Output = I64Vec2;
796    #[inline]
797    fn div(self, rhs: &I64Vec2) -> I64Vec2 {
798        (*self).div(*rhs)
799    }
800}
801
802impl Div<I64Vec2> for &I64Vec2 {
803    type Output = I64Vec2;
804    #[inline]
805    fn div(self, rhs: I64Vec2) -> I64Vec2 {
806        (*self).div(rhs)
807    }
808}
809
810impl DivAssign<I64Vec2> for I64Vec2 {
811    #[inline]
812    fn div_assign(&mut self, rhs: Self) {
813        self.x.div_assign(rhs.x);
814        self.y.div_assign(rhs.y);
815    }
816}
817
818impl DivAssign<&I64Vec2> for I64Vec2 {
819    #[inline]
820    fn div_assign(&mut self, rhs: &I64Vec2) {
821        self.div_assign(*rhs)
822    }
823}
824
825impl Div<i64> for I64Vec2 {
826    type Output = Self;
827    #[inline]
828    fn div(self, rhs: i64) -> Self {
829        Self {
830            x: self.x.div(rhs),
831            y: self.y.div(rhs),
832        }
833    }
834}
835
836impl Div<&i64> for I64Vec2 {
837    type Output = I64Vec2;
838    #[inline]
839    fn div(self, rhs: &i64) -> I64Vec2 {
840        self.div(*rhs)
841    }
842}
843
844impl Div<&i64> for &I64Vec2 {
845    type Output = I64Vec2;
846    #[inline]
847    fn div(self, rhs: &i64) -> I64Vec2 {
848        (*self).div(*rhs)
849    }
850}
851
852impl Div<i64> for &I64Vec2 {
853    type Output = I64Vec2;
854    #[inline]
855    fn div(self, rhs: i64) -> I64Vec2 {
856        (*self).div(rhs)
857    }
858}
859
860impl DivAssign<i64> for I64Vec2 {
861    #[inline]
862    fn div_assign(&mut self, rhs: i64) {
863        self.x.div_assign(rhs);
864        self.y.div_assign(rhs);
865    }
866}
867
868impl DivAssign<&i64> for I64Vec2 {
869    #[inline]
870    fn div_assign(&mut self, rhs: &i64) {
871        self.div_assign(*rhs)
872    }
873}
874
875impl Div<I64Vec2> for i64 {
876    type Output = I64Vec2;
877    #[inline]
878    fn div(self, rhs: I64Vec2) -> I64Vec2 {
879        I64Vec2 {
880            x: self.div(rhs.x),
881            y: self.div(rhs.y),
882        }
883    }
884}
885
886impl Div<&I64Vec2> for i64 {
887    type Output = I64Vec2;
888    #[inline]
889    fn div(self, rhs: &I64Vec2) -> I64Vec2 {
890        self.div(*rhs)
891    }
892}
893
894impl Div<&I64Vec2> for &i64 {
895    type Output = I64Vec2;
896    #[inline]
897    fn div(self, rhs: &I64Vec2) -> I64Vec2 {
898        (*self).div(*rhs)
899    }
900}
901
902impl Div<I64Vec2> for &i64 {
903    type Output = I64Vec2;
904    #[inline]
905    fn div(self, rhs: I64Vec2) -> I64Vec2 {
906        (*self).div(rhs)
907    }
908}
909
910impl Mul<I64Vec2> for I64Vec2 {
911    type Output = Self;
912    #[inline]
913    fn mul(self, rhs: Self) -> Self {
914        Self {
915            x: self.x.mul(rhs.x),
916            y: self.y.mul(rhs.y),
917        }
918    }
919}
920
921impl Mul<&I64Vec2> for I64Vec2 {
922    type Output = I64Vec2;
923    #[inline]
924    fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
925        self.mul(*rhs)
926    }
927}
928
929impl Mul<&I64Vec2> for &I64Vec2 {
930    type Output = I64Vec2;
931    #[inline]
932    fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
933        (*self).mul(*rhs)
934    }
935}
936
937impl Mul<I64Vec2> for &I64Vec2 {
938    type Output = I64Vec2;
939    #[inline]
940    fn mul(self, rhs: I64Vec2) -> I64Vec2 {
941        (*self).mul(rhs)
942    }
943}
944
945impl MulAssign<I64Vec2> for I64Vec2 {
946    #[inline]
947    fn mul_assign(&mut self, rhs: Self) {
948        self.x.mul_assign(rhs.x);
949        self.y.mul_assign(rhs.y);
950    }
951}
952
953impl MulAssign<&I64Vec2> for I64Vec2 {
954    #[inline]
955    fn mul_assign(&mut self, rhs: &I64Vec2) {
956        self.mul_assign(*rhs)
957    }
958}
959
960impl Mul<i64> for I64Vec2 {
961    type Output = Self;
962    #[inline]
963    fn mul(self, rhs: i64) -> Self {
964        Self {
965            x: self.x.mul(rhs),
966            y: self.y.mul(rhs),
967        }
968    }
969}
970
971impl Mul<&i64> for I64Vec2 {
972    type Output = I64Vec2;
973    #[inline]
974    fn mul(self, rhs: &i64) -> I64Vec2 {
975        self.mul(*rhs)
976    }
977}
978
979impl Mul<&i64> for &I64Vec2 {
980    type Output = I64Vec2;
981    #[inline]
982    fn mul(self, rhs: &i64) -> I64Vec2 {
983        (*self).mul(*rhs)
984    }
985}
986
987impl Mul<i64> for &I64Vec2 {
988    type Output = I64Vec2;
989    #[inline]
990    fn mul(self, rhs: i64) -> I64Vec2 {
991        (*self).mul(rhs)
992    }
993}
994
995impl MulAssign<i64> for I64Vec2 {
996    #[inline]
997    fn mul_assign(&mut self, rhs: i64) {
998        self.x.mul_assign(rhs);
999        self.y.mul_assign(rhs);
1000    }
1001}
1002
1003impl MulAssign<&i64> for I64Vec2 {
1004    #[inline]
1005    fn mul_assign(&mut self, rhs: &i64) {
1006        self.mul_assign(*rhs)
1007    }
1008}
1009
1010impl Mul<I64Vec2> for i64 {
1011    type Output = I64Vec2;
1012    #[inline]
1013    fn mul(self, rhs: I64Vec2) -> I64Vec2 {
1014        I64Vec2 {
1015            x: self.mul(rhs.x),
1016            y: self.mul(rhs.y),
1017        }
1018    }
1019}
1020
1021impl Mul<&I64Vec2> for i64 {
1022    type Output = I64Vec2;
1023    #[inline]
1024    fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
1025        self.mul(*rhs)
1026    }
1027}
1028
1029impl Mul<&I64Vec2> for &i64 {
1030    type Output = I64Vec2;
1031    #[inline]
1032    fn mul(self, rhs: &I64Vec2) -> I64Vec2 {
1033        (*self).mul(*rhs)
1034    }
1035}
1036
1037impl Mul<I64Vec2> for &i64 {
1038    type Output = I64Vec2;
1039    #[inline]
1040    fn mul(self, rhs: I64Vec2) -> I64Vec2 {
1041        (*self).mul(rhs)
1042    }
1043}
1044
1045impl Add<I64Vec2> for I64Vec2 {
1046    type Output = Self;
1047    #[inline]
1048    fn add(self, rhs: Self) -> Self {
1049        Self {
1050            x: self.x.add(rhs.x),
1051            y: self.y.add(rhs.y),
1052        }
1053    }
1054}
1055
1056impl Add<&I64Vec2> for I64Vec2 {
1057    type Output = I64Vec2;
1058    #[inline]
1059    fn add(self, rhs: &I64Vec2) -> I64Vec2 {
1060        self.add(*rhs)
1061    }
1062}
1063
1064impl Add<&I64Vec2> for &I64Vec2 {
1065    type Output = I64Vec2;
1066    #[inline]
1067    fn add(self, rhs: &I64Vec2) -> I64Vec2 {
1068        (*self).add(*rhs)
1069    }
1070}
1071
1072impl Add<I64Vec2> for &I64Vec2 {
1073    type Output = I64Vec2;
1074    #[inline]
1075    fn add(self, rhs: I64Vec2) -> I64Vec2 {
1076        (*self).add(rhs)
1077    }
1078}
1079
1080impl AddAssign<I64Vec2> for I64Vec2 {
1081    #[inline]
1082    fn add_assign(&mut self, rhs: Self) {
1083        self.x.add_assign(rhs.x);
1084        self.y.add_assign(rhs.y);
1085    }
1086}
1087
1088impl AddAssign<&I64Vec2> for I64Vec2 {
1089    #[inline]
1090    fn add_assign(&mut self, rhs: &I64Vec2) {
1091        self.add_assign(*rhs)
1092    }
1093}
1094
1095impl Add<i64> for I64Vec2 {
1096    type Output = Self;
1097    #[inline]
1098    fn add(self, rhs: i64) -> Self {
1099        Self {
1100            x: self.x.add(rhs),
1101            y: self.y.add(rhs),
1102        }
1103    }
1104}
1105
1106impl Add<&i64> for I64Vec2 {
1107    type Output = I64Vec2;
1108    #[inline]
1109    fn add(self, rhs: &i64) -> I64Vec2 {
1110        self.add(*rhs)
1111    }
1112}
1113
1114impl Add<&i64> for &I64Vec2 {
1115    type Output = I64Vec2;
1116    #[inline]
1117    fn add(self, rhs: &i64) -> I64Vec2 {
1118        (*self).add(*rhs)
1119    }
1120}
1121
1122impl Add<i64> for &I64Vec2 {
1123    type Output = I64Vec2;
1124    #[inline]
1125    fn add(self, rhs: i64) -> I64Vec2 {
1126        (*self).add(rhs)
1127    }
1128}
1129
1130impl AddAssign<i64> for I64Vec2 {
1131    #[inline]
1132    fn add_assign(&mut self, rhs: i64) {
1133        self.x.add_assign(rhs);
1134        self.y.add_assign(rhs);
1135    }
1136}
1137
1138impl AddAssign<&i64> for I64Vec2 {
1139    #[inline]
1140    fn add_assign(&mut self, rhs: &i64) {
1141        self.add_assign(*rhs)
1142    }
1143}
1144
1145impl Add<I64Vec2> for i64 {
1146    type Output = I64Vec2;
1147    #[inline]
1148    fn add(self, rhs: I64Vec2) -> I64Vec2 {
1149        I64Vec2 {
1150            x: self.add(rhs.x),
1151            y: self.add(rhs.y),
1152        }
1153    }
1154}
1155
1156impl Add<&I64Vec2> for i64 {
1157    type Output = I64Vec2;
1158    #[inline]
1159    fn add(self, rhs: &I64Vec2) -> I64Vec2 {
1160        self.add(*rhs)
1161    }
1162}
1163
1164impl Add<&I64Vec2> for &i64 {
1165    type Output = I64Vec2;
1166    #[inline]
1167    fn add(self, rhs: &I64Vec2) -> I64Vec2 {
1168        (*self).add(*rhs)
1169    }
1170}
1171
1172impl Add<I64Vec2> for &i64 {
1173    type Output = I64Vec2;
1174    #[inline]
1175    fn add(self, rhs: I64Vec2) -> I64Vec2 {
1176        (*self).add(rhs)
1177    }
1178}
1179
1180impl Sub<I64Vec2> for I64Vec2 {
1181    type Output = Self;
1182    #[inline]
1183    fn sub(self, rhs: Self) -> Self {
1184        Self {
1185            x: self.x.sub(rhs.x),
1186            y: self.y.sub(rhs.y),
1187        }
1188    }
1189}
1190
1191impl Sub<&I64Vec2> for I64Vec2 {
1192    type Output = I64Vec2;
1193    #[inline]
1194    fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
1195        self.sub(*rhs)
1196    }
1197}
1198
1199impl Sub<&I64Vec2> for &I64Vec2 {
1200    type Output = I64Vec2;
1201    #[inline]
1202    fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
1203        (*self).sub(*rhs)
1204    }
1205}
1206
1207impl Sub<I64Vec2> for &I64Vec2 {
1208    type Output = I64Vec2;
1209    #[inline]
1210    fn sub(self, rhs: I64Vec2) -> I64Vec2 {
1211        (*self).sub(rhs)
1212    }
1213}
1214
1215impl SubAssign<I64Vec2> for I64Vec2 {
1216    #[inline]
1217    fn sub_assign(&mut self, rhs: I64Vec2) {
1218        self.x.sub_assign(rhs.x);
1219        self.y.sub_assign(rhs.y);
1220    }
1221}
1222
1223impl SubAssign<&I64Vec2> for I64Vec2 {
1224    #[inline]
1225    fn sub_assign(&mut self, rhs: &I64Vec2) {
1226        self.sub_assign(*rhs)
1227    }
1228}
1229
1230impl Sub<i64> for I64Vec2 {
1231    type Output = Self;
1232    #[inline]
1233    fn sub(self, rhs: i64) -> Self {
1234        Self {
1235            x: self.x.sub(rhs),
1236            y: self.y.sub(rhs),
1237        }
1238    }
1239}
1240
1241impl Sub<&i64> for I64Vec2 {
1242    type Output = I64Vec2;
1243    #[inline]
1244    fn sub(self, rhs: &i64) -> I64Vec2 {
1245        self.sub(*rhs)
1246    }
1247}
1248
1249impl Sub<&i64> for &I64Vec2 {
1250    type Output = I64Vec2;
1251    #[inline]
1252    fn sub(self, rhs: &i64) -> I64Vec2 {
1253        (*self).sub(*rhs)
1254    }
1255}
1256
1257impl Sub<i64> for &I64Vec2 {
1258    type Output = I64Vec2;
1259    #[inline]
1260    fn sub(self, rhs: i64) -> I64Vec2 {
1261        (*self).sub(rhs)
1262    }
1263}
1264
1265impl SubAssign<i64> for I64Vec2 {
1266    #[inline]
1267    fn sub_assign(&mut self, rhs: i64) {
1268        self.x.sub_assign(rhs);
1269        self.y.sub_assign(rhs);
1270    }
1271}
1272
1273impl SubAssign<&i64> for I64Vec2 {
1274    #[inline]
1275    fn sub_assign(&mut self, rhs: &i64) {
1276        self.sub_assign(*rhs)
1277    }
1278}
1279
1280impl Sub<I64Vec2> for i64 {
1281    type Output = I64Vec2;
1282    #[inline]
1283    fn sub(self, rhs: I64Vec2) -> I64Vec2 {
1284        I64Vec2 {
1285            x: self.sub(rhs.x),
1286            y: self.sub(rhs.y),
1287        }
1288    }
1289}
1290
1291impl Sub<&I64Vec2> for i64 {
1292    type Output = I64Vec2;
1293    #[inline]
1294    fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
1295        self.sub(*rhs)
1296    }
1297}
1298
1299impl Sub<&I64Vec2> for &i64 {
1300    type Output = I64Vec2;
1301    #[inline]
1302    fn sub(self, rhs: &I64Vec2) -> I64Vec2 {
1303        (*self).sub(*rhs)
1304    }
1305}
1306
1307impl Sub<I64Vec2> for &i64 {
1308    type Output = I64Vec2;
1309    #[inline]
1310    fn sub(self, rhs: I64Vec2) -> I64Vec2 {
1311        (*self).sub(rhs)
1312    }
1313}
1314
1315impl Rem<I64Vec2> for I64Vec2 {
1316    type Output = Self;
1317    #[inline]
1318    fn rem(self, rhs: Self) -> Self {
1319        Self {
1320            x: self.x.rem(rhs.x),
1321            y: self.y.rem(rhs.y),
1322        }
1323    }
1324}
1325
1326impl Rem<&I64Vec2> for I64Vec2 {
1327    type Output = I64Vec2;
1328    #[inline]
1329    fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
1330        self.rem(*rhs)
1331    }
1332}
1333
1334impl Rem<&I64Vec2> for &I64Vec2 {
1335    type Output = I64Vec2;
1336    #[inline]
1337    fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
1338        (*self).rem(*rhs)
1339    }
1340}
1341
1342impl Rem<I64Vec2> for &I64Vec2 {
1343    type Output = I64Vec2;
1344    #[inline]
1345    fn rem(self, rhs: I64Vec2) -> I64Vec2 {
1346        (*self).rem(rhs)
1347    }
1348}
1349
1350impl RemAssign<I64Vec2> for I64Vec2 {
1351    #[inline]
1352    fn rem_assign(&mut self, rhs: Self) {
1353        self.x.rem_assign(rhs.x);
1354        self.y.rem_assign(rhs.y);
1355    }
1356}
1357
1358impl RemAssign<&I64Vec2> for I64Vec2 {
1359    #[inline]
1360    fn rem_assign(&mut self, rhs: &I64Vec2) {
1361        self.rem_assign(*rhs)
1362    }
1363}
1364
1365impl Rem<i64> for I64Vec2 {
1366    type Output = Self;
1367    #[inline]
1368    fn rem(self, rhs: i64) -> Self {
1369        Self {
1370            x: self.x.rem(rhs),
1371            y: self.y.rem(rhs),
1372        }
1373    }
1374}
1375
1376impl Rem<&i64> for I64Vec2 {
1377    type Output = I64Vec2;
1378    #[inline]
1379    fn rem(self, rhs: &i64) -> I64Vec2 {
1380        self.rem(*rhs)
1381    }
1382}
1383
1384impl Rem<&i64> for &I64Vec2 {
1385    type Output = I64Vec2;
1386    #[inline]
1387    fn rem(self, rhs: &i64) -> I64Vec2 {
1388        (*self).rem(*rhs)
1389    }
1390}
1391
1392impl Rem<i64> for &I64Vec2 {
1393    type Output = I64Vec2;
1394    #[inline]
1395    fn rem(self, rhs: i64) -> I64Vec2 {
1396        (*self).rem(rhs)
1397    }
1398}
1399
1400impl RemAssign<i64> for I64Vec2 {
1401    #[inline]
1402    fn rem_assign(&mut self, rhs: i64) {
1403        self.x.rem_assign(rhs);
1404        self.y.rem_assign(rhs);
1405    }
1406}
1407
1408impl RemAssign<&i64> for I64Vec2 {
1409    #[inline]
1410    fn rem_assign(&mut self, rhs: &i64) {
1411        self.rem_assign(*rhs)
1412    }
1413}
1414
1415impl Rem<I64Vec2> for i64 {
1416    type Output = I64Vec2;
1417    #[inline]
1418    fn rem(self, rhs: I64Vec2) -> I64Vec2 {
1419        I64Vec2 {
1420            x: self.rem(rhs.x),
1421            y: self.rem(rhs.y),
1422        }
1423    }
1424}
1425
1426impl Rem<&I64Vec2> for i64 {
1427    type Output = I64Vec2;
1428    #[inline]
1429    fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
1430        self.rem(*rhs)
1431    }
1432}
1433
1434impl Rem<&I64Vec2> for &i64 {
1435    type Output = I64Vec2;
1436    #[inline]
1437    fn rem(self, rhs: &I64Vec2) -> I64Vec2 {
1438        (*self).rem(*rhs)
1439    }
1440}
1441
1442impl Rem<I64Vec2> for &i64 {
1443    type Output = I64Vec2;
1444    #[inline]
1445    fn rem(self, rhs: I64Vec2) -> I64Vec2 {
1446        (*self).rem(rhs)
1447    }
1448}
1449
1450#[cfg(not(target_arch = "spirv"))]
1451impl AsRef<[i64; 2]> for I64Vec2 {
1452    #[inline]
1453    fn as_ref(&self) -> &[i64; 2] {
1454        unsafe { &*(self as *const I64Vec2 as *const [i64; 2]) }
1455    }
1456}
1457
1458#[cfg(not(target_arch = "spirv"))]
1459impl AsMut<[i64; 2]> for I64Vec2 {
1460    #[inline]
1461    fn as_mut(&mut self) -> &mut [i64; 2] {
1462        unsafe { &mut *(self as *mut I64Vec2 as *mut [i64; 2]) }
1463    }
1464}
1465
1466impl Sum for I64Vec2 {
1467    #[inline]
1468    fn sum<I>(iter: I) -> Self
1469    where
1470        I: Iterator<Item = Self>,
1471    {
1472        iter.fold(Self::ZERO, Self::add)
1473    }
1474}
1475
1476impl<'a> Sum<&'a Self> for I64Vec2 {
1477    #[inline]
1478    fn sum<I>(iter: I) -> Self
1479    where
1480        I: Iterator<Item = &'a Self>,
1481    {
1482        iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1483    }
1484}
1485
1486impl Product for I64Vec2 {
1487    #[inline]
1488    fn product<I>(iter: I) -> Self
1489    where
1490        I: Iterator<Item = Self>,
1491    {
1492        iter.fold(Self::ONE, Self::mul)
1493    }
1494}
1495
1496impl<'a> Product<&'a Self> for I64Vec2 {
1497    #[inline]
1498    fn product<I>(iter: I) -> Self
1499    where
1500        I: Iterator<Item = &'a Self>,
1501    {
1502        iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1503    }
1504}
1505
1506impl Neg for I64Vec2 {
1507    type Output = Self;
1508    #[inline]
1509    fn neg(self) -> Self {
1510        Self {
1511            x: self.x.neg(),
1512            y: self.y.neg(),
1513        }
1514    }
1515}
1516
1517impl Neg for &I64Vec2 {
1518    type Output = I64Vec2;
1519    #[inline]
1520    fn neg(self) -> I64Vec2 {
1521        (*self).neg()
1522    }
1523}
1524
1525impl Not for I64Vec2 {
1526    type Output = Self;
1527    #[inline]
1528    fn not(self) -> Self::Output {
1529        Self {
1530            x: self.x.not(),
1531            y: self.y.not(),
1532        }
1533    }
1534}
1535
1536impl BitAnd for I64Vec2 {
1537    type Output = Self;
1538    #[inline]
1539    fn bitand(self, rhs: Self) -> Self::Output {
1540        Self {
1541            x: self.x.bitand(rhs.x),
1542            y: self.y.bitand(rhs.y),
1543        }
1544    }
1545}
1546
1547impl BitOr for I64Vec2 {
1548    type Output = Self;
1549    #[inline]
1550    fn bitor(self, rhs: Self) -> Self::Output {
1551        Self {
1552            x: self.x.bitor(rhs.x),
1553            y: self.y.bitor(rhs.y),
1554        }
1555    }
1556}
1557
1558impl BitXor for I64Vec2 {
1559    type Output = Self;
1560    #[inline]
1561    fn bitxor(self, rhs: Self) -> Self::Output {
1562        Self {
1563            x: self.x.bitxor(rhs.x),
1564            y: self.y.bitxor(rhs.y),
1565        }
1566    }
1567}
1568
1569impl BitAnd<i64> for I64Vec2 {
1570    type Output = Self;
1571    #[inline]
1572    fn bitand(self, rhs: i64) -> Self::Output {
1573        Self {
1574            x: self.x.bitand(rhs),
1575            y: self.y.bitand(rhs),
1576        }
1577    }
1578}
1579
1580impl BitOr<i64> for I64Vec2 {
1581    type Output = Self;
1582    #[inline]
1583    fn bitor(self, rhs: i64) -> Self::Output {
1584        Self {
1585            x: self.x.bitor(rhs),
1586            y: self.y.bitor(rhs),
1587        }
1588    }
1589}
1590
1591impl BitXor<i64> for I64Vec2 {
1592    type Output = Self;
1593    #[inline]
1594    fn bitxor(self, rhs: i64) -> Self::Output {
1595        Self {
1596            x: self.x.bitxor(rhs),
1597            y: self.y.bitxor(rhs),
1598        }
1599    }
1600}
1601
1602impl Shl<i8> for I64Vec2 {
1603    type Output = Self;
1604    #[inline]
1605    fn shl(self, rhs: i8) -> Self::Output {
1606        Self {
1607            x: self.x.shl(rhs),
1608            y: self.y.shl(rhs),
1609        }
1610    }
1611}
1612
1613impl Shr<i8> for I64Vec2 {
1614    type Output = Self;
1615    #[inline]
1616    fn shr(self, rhs: i8) -> Self::Output {
1617        Self {
1618            x: self.x.shr(rhs),
1619            y: self.y.shr(rhs),
1620        }
1621    }
1622}
1623
1624impl Shl<i16> for I64Vec2 {
1625    type Output = Self;
1626    #[inline]
1627    fn shl(self, rhs: i16) -> Self::Output {
1628        Self {
1629            x: self.x.shl(rhs),
1630            y: self.y.shl(rhs),
1631        }
1632    }
1633}
1634
1635impl Shr<i16> for I64Vec2 {
1636    type Output = Self;
1637    #[inline]
1638    fn shr(self, rhs: i16) -> Self::Output {
1639        Self {
1640            x: self.x.shr(rhs),
1641            y: self.y.shr(rhs),
1642        }
1643    }
1644}
1645
1646impl Shl<i32> for I64Vec2 {
1647    type Output = Self;
1648    #[inline]
1649    fn shl(self, rhs: i32) -> Self::Output {
1650        Self {
1651            x: self.x.shl(rhs),
1652            y: self.y.shl(rhs),
1653        }
1654    }
1655}
1656
1657impl Shr<i32> for I64Vec2 {
1658    type Output = Self;
1659    #[inline]
1660    fn shr(self, rhs: i32) -> Self::Output {
1661        Self {
1662            x: self.x.shr(rhs),
1663            y: self.y.shr(rhs),
1664        }
1665    }
1666}
1667
1668impl Shl<i64> for I64Vec2 {
1669    type Output = Self;
1670    #[inline]
1671    fn shl(self, rhs: i64) -> Self::Output {
1672        Self {
1673            x: self.x.shl(rhs),
1674            y: self.y.shl(rhs),
1675        }
1676    }
1677}
1678
1679impl Shr<i64> for I64Vec2 {
1680    type Output = Self;
1681    #[inline]
1682    fn shr(self, rhs: i64) -> Self::Output {
1683        Self {
1684            x: self.x.shr(rhs),
1685            y: self.y.shr(rhs),
1686        }
1687    }
1688}
1689
1690impl Shl<u8> for I64Vec2 {
1691    type Output = Self;
1692    #[inline]
1693    fn shl(self, rhs: u8) -> Self::Output {
1694        Self {
1695            x: self.x.shl(rhs),
1696            y: self.y.shl(rhs),
1697        }
1698    }
1699}
1700
1701impl Shr<u8> for I64Vec2 {
1702    type Output = Self;
1703    #[inline]
1704    fn shr(self, rhs: u8) -> Self::Output {
1705        Self {
1706            x: self.x.shr(rhs),
1707            y: self.y.shr(rhs),
1708        }
1709    }
1710}
1711
1712impl Shl<u16> for I64Vec2 {
1713    type Output = Self;
1714    #[inline]
1715    fn shl(self, rhs: u16) -> Self::Output {
1716        Self {
1717            x: self.x.shl(rhs),
1718            y: self.y.shl(rhs),
1719        }
1720    }
1721}
1722
1723impl Shr<u16> for I64Vec2 {
1724    type Output = Self;
1725    #[inline]
1726    fn shr(self, rhs: u16) -> Self::Output {
1727        Self {
1728            x: self.x.shr(rhs),
1729            y: self.y.shr(rhs),
1730        }
1731    }
1732}
1733
1734impl Shl<u32> for I64Vec2 {
1735    type Output = Self;
1736    #[inline]
1737    fn shl(self, rhs: u32) -> Self::Output {
1738        Self {
1739            x: self.x.shl(rhs),
1740            y: self.y.shl(rhs),
1741        }
1742    }
1743}
1744
1745impl Shr<u32> for I64Vec2 {
1746    type Output = Self;
1747    #[inline]
1748    fn shr(self, rhs: u32) -> Self::Output {
1749        Self {
1750            x: self.x.shr(rhs),
1751            y: self.y.shr(rhs),
1752        }
1753    }
1754}
1755
1756impl Shl<u64> for I64Vec2 {
1757    type Output = Self;
1758    #[inline]
1759    fn shl(self, rhs: u64) -> Self::Output {
1760        Self {
1761            x: self.x.shl(rhs),
1762            y: self.y.shl(rhs),
1763        }
1764    }
1765}
1766
1767impl Shr<u64> for I64Vec2 {
1768    type Output = Self;
1769    #[inline]
1770    fn shr(self, rhs: u64) -> Self::Output {
1771        Self {
1772            x: self.x.shr(rhs),
1773            y: self.y.shr(rhs),
1774        }
1775    }
1776}
1777
1778impl Shl<crate::IVec2> for I64Vec2 {
1779    type Output = Self;
1780    #[inline]
1781    fn shl(self, rhs: crate::IVec2) -> Self::Output {
1782        Self {
1783            x: self.x.shl(rhs.x),
1784            y: self.y.shl(rhs.y),
1785        }
1786    }
1787}
1788
1789impl Shr<crate::IVec2> for I64Vec2 {
1790    type Output = Self;
1791    #[inline]
1792    fn shr(self, rhs: crate::IVec2) -> Self::Output {
1793        Self {
1794            x: self.x.shr(rhs.x),
1795            y: self.y.shr(rhs.y),
1796        }
1797    }
1798}
1799
1800impl Shl<crate::UVec2> for I64Vec2 {
1801    type Output = Self;
1802    #[inline]
1803    fn shl(self, rhs: crate::UVec2) -> Self::Output {
1804        Self {
1805            x: self.x.shl(rhs.x),
1806            y: self.y.shl(rhs.y),
1807        }
1808    }
1809}
1810
1811impl Shr<crate::UVec2> for I64Vec2 {
1812    type Output = Self;
1813    #[inline]
1814    fn shr(self, rhs: crate::UVec2) -> Self::Output {
1815        Self {
1816            x: self.x.shr(rhs.x),
1817            y: self.y.shr(rhs.y),
1818        }
1819    }
1820}
1821
1822impl Index<usize> for I64Vec2 {
1823    type Output = i64;
1824    #[inline]
1825    fn index(&self, index: usize) -> &Self::Output {
1826        match index {
1827            0 => &self.x,
1828            1 => &self.y,
1829            _ => panic!("index out of bounds"),
1830        }
1831    }
1832}
1833
1834impl IndexMut<usize> for I64Vec2 {
1835    #[inline]
1836    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1837        match index {
1838            0 => &mut self.x,
1839            1 => &mut self.y,
1840            _ => panic!("index out of bounds"),
1841        }
1842    }
1843}
1844
1845impl fmt::Display for I64Vec2 {
1846    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1847        write!(f, "[{}, {}]", self.x, self.y)
1848    }
1849}
1850
1851impl fmt::Debug for I64Vec2 {
1852    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1853        fmt.debug_tuple(stringify!(I64Vec2))
1854            .field(&self.x)
1855            .field(&self.y)
1856            .finish()
1857    }
1858}
1859
1860impl From<[i64; 2]> for I64Vec2 {
1861    #[inline]
1862    fn from(a: [i64; 2]) -> Self {
1863        Self::new(a[0], a[1])
1864    }
1865}
1866
1867impl From<I64Vec2> for [i64; 2] {
1868    #[inline]
1869    fn from(v: I64Vec2) -> Self {
1870        [v.x, v.y]
1871    }
1872}
1873
1874impl From<(i64, i64)> for I64Vec2 {
1875    #[inline]
1876    fn from(t: (i64, i64)) -> Self {
1877        Self::new(t.0, t.1)
1878    }
1879}
1880
1881impl From<I64Vec2> for (i64, i64) {
1882    #[inline]
1883    fn from(v: I64Vec2) -> Self {
1884        (v.x, v.y)
1885    }
1886}
1887
1888impl From<I8Vec2> for I64Vec2 {
1889    #[inline]
1890    fn from(v: I8Vec2) -> Self {
1891        Self::new(i64::from(v.x), i64::from(v.y))
1892    }
1893}
1894
1895impl From<U8Vec2> for I64Vec2 {
1896    #[inline]
1897    fn from(v: U8Vec2) -> Self {
1898        Self::new(i64::from(v.x), i64::from(v.y))
1899    }
1900}
1901
1902impl From<I16Vec2> for I64Vec2 {
1903    #[inline]
1904    fn from(v: I16Vec2) -> Self {
1905        Self::new(i64::from(v.x), i64::from(v.y))
1906    }
1907}
1908
1909impl From<U16Vec2> for I64Vec2 {
1910    #[inline]
1911    fn from(v: U16Vec2) -> Self {
1912        Self::new(i64::from(v.x), i64::from(v.y))
1913    }
1914}
1915
1916impl From<IVec2> for I64Vec2 {
1917    #[inline]
1918    fn from(v: IVec2) -> Self {
1919        Self::new(i64::from(v.x), i64::from(v.y))
1920    }
1921}
1922
1923impl From<UVec2> for I64Vec2 {
1924    #[inline]
1925    fn from(v: UVec2) -> Self {
1926        Self::new(i64::from(v.x), i64::from(v.y))
1927    }
1928}
1929
1930impl TryFrom<U64Vec2> for I64Vec2 {
1931    type Error = core::num::TryFromIntError;
1932
1933    #[inline]
1934    fn try_from(v: U64Vec2) -> Result<Self, Self::Error> {
1935        Ok(Self::new(i64::try_from(v.x)?, i64::try_from(v.y)?))
1936    }
1937}
1938
1939impl From<BVec2> for I64Vec2 {
1940    #[inline]
1941    fn from(v: BVec2) -> Self {
1942        Self::new(i64::from(v.x), i64::from(v.y))
1943    }
1944}