1 // Generated from vec.rs.tera template. Edit the template, not the generated file.
2 
3 use crate::{BVec4, I16Vec4, I64Vec4, IVec2, IVec3, U16Vec4, U64Vec4, UVec4};
4 
5 #[cfg(not(target_arch = "spirv"))]
6 use core::fmt;
7 use core::iter::{Product, Sum};
8 use core::{f32, ops::*};
9 
10 /// Creates a 4-dimensional vector.
11 #[inline(always)]
12 #[must_use]
ivec4(x: i32, y: i32, z: i32, w: i32) -> IVec413 pub const fn ivec4(x: i32, y: i32, z: i32, w: i32) -> IVec4 {
14     IVec4::new(x, y, z, w)
15 }
16 
17 /// A 4-dimensional vector.
18 #[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
19 #[derive(Clone, Copy, PartialEq, Eq)]
20 #[cfg_attr(feature = "cuda", repr(align(16)))]
21 #[cfg_attr(not(target_arch = "spirv"), repr(C))]
22 #[cfg_attr(target_arch = "spirv", repr(simd))]
23 pub struct IVec4 {
24     pub x: i32,
25     pub y: i32,
26     pub z: i32,
27     pub w: i32,
28 }
29 
30 impl IVec4 {
31     /// All zeroes.
32     pub const ZERO: Self = Self::splat(0);
33 
34     /// All ones.
35     pub const ONE: Self = Self::splat(1);
36 
37     /// All negative ones.
38     pub const NEG_ONE: Self = Self::splat(-1);
39 
40     /// All `i32::MIN`.
41     pub const MIN: Self = Self::splat(i32::MIN);
42 
43     /// All `i32::MAX`.
44     pub const MAX: Self = Self::splat(i32::MAX);
45 
46     /// A unit vector pointing along the positive X axis.
47     pub const X: Self = Self::new(1, 0, 0, 0);
48 
49     /// A unit vector pointing along the positive Y axis.
50     pub const Y: Self = Self::new(0, 1, 0, 0);
51 
52     /// A unit vector pointing along the positive Z axis.
53     pub const Z: Self = Self::new(0, 0, 1, 0);
54 
55     /// A unit vector pointing along the positive W axis.
56     pub const W: Self = Self::new(0, 0, 0, 1);
57 
58     /// A unit vector pointing along the negative X axis.
59     pub const NEG_X: Self = Self::new(-1, 0, 0, 0);
60 
61     /// A unit vector pointing along the negative Y axis.
62     pub const NEG_Y: Self = Self::new(0, -1, 0, 0);
63 
64     /// A unit vector pointing along the negative Z axis.
65     pub const NEG_Z: Self = Self::new(0, 0, -1, 0);
66 
67     /// A unit vector pointing along the negative W axis.
68     pub const NEG_W: Self = Self::new(0, 0, 0, -1);
69 
70     /// The unit axes.
71     pub const AXES: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
72 
73     /// Creates a new vector.
74     #[inline(always)]
75     #[must_use]
new(x: i32, y: i32, z: i32, w: i32) -> Self76     pub const fn new(x: i32, y: i32, z: i32, w: i32) -> Self {
77         Self { x, y, z, w }
78     }
79 
80     /// Creates a vector with all elements set to `v`.
81     #[inline]
82     #[must_use]
splat(v: i32) -> Self83     pub const fn splat(v: i32) -> Self {
84         Self {
85             x: v,
86 
87             y: v,
88 
89             z: v,
90 
91             w: v,
92         }
93     }
94 
95     /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
96     /// for each element of `self`.
97     ///
98     /// A true element in the mask uses the corresponding element from `if_true`, and false
99     /// uses the element from `if_false`.
100     #[inline]
101     #[must_use]
select(mask: BVec4, if_true: Self, if_false: Self) -> Self102     pub fn select(mask: BVec4, if_true: Self, if_false: Self) -> Self {
103         Self {
104             x: if mask.test(0) { if_true.x } else { if_false.x },
105             y: if mask.test(1) { if_true.y } else { if_false.y },
106             z: if mask.test(2) { if_true.z } else { if_false.z },
107             w: if mask.test(3) { if_true.w } else { if_false.w },
108         }
109     }
110 
111     /// Creates a new vector from an array.
112     #[inline]
113     #[must_use]
from_array(a: [i32; 4]) -> Self114     pub const fn from_array(a: [i32; 4]) -> Self {
115         Self::new(a[0], a[1], a[2], a[3])
116     }
117 
118     /// `[x, y, z, w]`
119     #[inline]
120     #[must_use]
to_array(&self) -> [i32; 4]121     pub const fn to_array(&self) -> [i32; 4] {
122         [self.x, self.y, self.z, self.w]
123     }
124 
125     /// Creates a vector from the first 4 values in `slice`.
126     ///
127     /// # Panics
128     ///
129     /// Panics if `slice` is less than 4 elements long.
130     #[inline]
131     #[must_use]
from_slice(slice: &[i32]) -> Self132     pub const fn from_slice(slice: &[i32]) -> Self {
133         Self::new(slice[0], slice[1], slice[2], slice[3])
134     }
135 
136     /// Writes the elements of `self` to the first 4 elements in `slice`.
137     ///
138     /// # Panics
139     ///
140     /// Panics if `slice` is less than 4 elements long.
141     #[inline]
write_to_slice(self, slice: &mut [i32])142     pub fn write_to_slice(self, slice: &mut [i32]) {
143         slice[0] = self.x;
144         slice[1] = self.y;
145         slice[2] = self.z;
146         slice[3] = self.w;
147     }
148 
149     /// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`.
150     ///
151     /// Truncation to [`IVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()].
152     #[inline]
153     #[must_use]
truncate(self) -> IVec3154     pub fn truncate(self) -> IVec3 {
155         use crate::swizzles::Vec4Swizzles;
156         self.xyz()
157     }
158 
159     /// Computes the dot product of `self` and `rhs`.
160     #[inline]
161     #[must_use]
dot(self, rhs: Self) -> i32162     pub fn dot(self, rhs: Self) -> i32 {
163         (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) + (self.w * rhs.w)
164     }
165 
166     /// Returns a vector where every component is the dot product of `self` and `rhs`.
167     #[inline]
168     #[must_use]
dot_into_vec(self, rhs: Self) -> Self169     pub fn dot_into_vec(self, rhs: Self) -> Self {
170         Self::splat(self.dot(rhs))
171     }
172 
173     /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
174     ///
175     /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
176     #[inline]
177     #[must_use]
min(self, rhs: Self) -> Self178     pub fn min(self, rhs: Self) -> Self {
179         Self {
180             x: self.x.min(rhs.x),
181             y: self.y.min(rhs.y),
182             z: self.z.min(rhs.z),
183             w: self.w.min(rhs.w),
184         }
185     }
186 
187     /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
188     ///
189     /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
190     #[inline]
191     #[must_use]
max(self, rhs: Self) -> Self192     pub fn max(self, rhs: Self) -> Self {
193         Self {
194             x: self.x.max(rhs.x),
195             y: self.y.max(rhs.y),
196             z: self.z.max(rhs.z),
197             w: self.w.max(rhs.w),
198         }
199     }
200 
201     /// Component-wise clamping of values, similar to [`i32::clamp`].
202     ///
203     /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
204     ///
205     /// # Panics
206     ///
207     /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
208     #[inline]
209     #[must_use]
clamp(self, min: Self, max: Self) -> Self210     pub fn clamp(self, min: Self, max: Self) -> Self {
211         glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
212         self.max(min).min(max)
213     }
214 
215     /// Returns the horizontal minimum of `self`.
216     ///
217     /// In other words this computes `min(x, y, ..)`.
218     #[inline]
219     #[must_use]
min_element(self) -> i32220     pub fn min_element(self) -> i32 {
221         self.x.min(self.y.min(self.z.min(self.w)))
222     }
223 
224     /// Returns the horizontal maximum of `self`.
225     ///
226     /// In other words this computes `max(x, y, ..)`.
227     #[inline]
228     #[must_use]
max_element(self) -> i32229     pub fn max_element(self) -> i32 {
230         self.x.max(self.y.max(self.z.max(self.w)))
231     }
232 
233     /// Returns a vector mask containing the result of a `==` comparison for each element of
234     /// `self` and `rhs`.
235     ///
236     /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
237     /// elements.
238     #[inline]
239     #[must_use]
cmpeq(self, rhs: Self) -> BVec4240     pub fn cmpeq(self, rhs: Self) -> BVec4 {
241         BVec4::new(
242             self.x.eq(&rhs.x),
243             self.y.eq(&rhs.y),
244             self.z.eq(&rhs.z),
245             self.w.eq(&rhs.w),
246         )
247     }
248 
249     /// Returns a vector mask containing the result of a `!=` comparison for each element of
250     /// `self` and `rhs`.
251     ///
252     /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
253     /// elements.
254     #[inline]
255     #[must_use]
cmpne(self, rhs: Self) -> BVec4256     pub fn cmpne(self, rhs: Self) -> BVec4 {
257         BVec4::new(
258             self.x.ne(&rhs.x),
259             self.y.ne(&rhs.y),
260             self.z.ne(&rhs.z),
261             self.w.ne(&rhs.w),
262         )
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]
cmpge(self, rhs: Self) -> BVec4272     pub fn cmpge(self, rhs: Self) -> BVec4 {
273         BVec4::new(
274             self.x.ge(&rhs.x),
275             self.y.ge(&rhs.y),
276             self.z.ge(&rhs.z),
277             self.w.ge(&rhs.w),
278         )
279     }
280 
281     /// Returns a vector mask containing the result of a `>` comparison for each element of
282     /// `self` and `rhs`.
283     ///
284     /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
285     /// elements.
286     #[inline]
287     #[must_use]
cmpgt(self, rhs: Self) -> BVec4288     pub fn cmpgt(self, rhs: Self) -> BVec4 {
289         BVec4::new(
290             self.x.gt(&rhs.x),
291             self.y.gt(&rhs.y),
292             self.z.gt(&rhs.z),
293             self.w.gt(&rhs.w),
294         )
295     }
296 
297     /// Returns a vector mask containing the result of a `<=` comparison for each element of
298     /// `self` and `rhs`.
299     ///
300     /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
301     /// elements.
302     #[inline]
303     #[must_use]
cmple(self, rhs: Self) -> BVec4304     pub fn cmple(self, rhs: Self) -> BVec4 {
305         BVec4::new(
306             self.x.le(&rhs.x),
307             self.y.le(&rhs.y),
308             self.z.le(&rhs.z),
309             self.w.le(&rhs.w),
310         )
311     }
312 
313     /// Returns a vector mask containing the result of a `<` comparison for each element of
314     /// `self` and `rhs`.
315     ///
316     /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
317     /// elements.
318     #[inline]
319     #[must_use]
cmplt(self, rhs: Self) -> BVec4320     pub fn cmplt(self, rhs: Self) -> BVec4 {
321         BVec4::new(
322             self.x.lt(&rhs.x),
323             self.y.lt(&rhs.y),
324             self.z.lt(&rhs.z),
325             self.w.lt(&rhs.w),
326         )
327     }
328 
329     /// Returns a vector containing the absolute value of each element of `self`.
330     #[inline]
331     #[must_use]
abs(self) -> Self332     pub fn abs(self) -> Self {
333         Self {
334             x: self.x.abs(),
335             y: self.y.abs(),
336             z: self.z.abs(),
337             w: self.w.abs(),
338         }
339     }
340 
341     /// Returns a vector with elements representing the sign of `self`.
342     ///
343     ///  - `0` if the number is zero
344     ///  - `1` if the number is positive
345     ///  - `-1` if the number is negative
346     #[inline]
347     #[must_use]
signum(self) -> Self348     pub fn signum(self) -> Self {
349         Self {
350             x: self.x.signum(),
351             y: self.y.signum(),
352             z: self.z.signum(),
353             w: self.w.signum(),
354         }
355     }
356 
357     /// Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`.
358     ///
359     /// A negative element results in a `1` bit and a positive element in a `0` bit.  Element `x` goes
360     /// into the first lowest bit, element `y` into the second, etc.
361     #[inline]
362     #[must_use]
is_negative_bitmask(self) -> u32363     pub fn is_negative_bitmask(self) -> u32 {
364         (self.x.is_negative() as u32)
365             | (self.y.is_negative() as u32) << 1
366             | (self.z.is_negative() as u32) << 2
367             | (self.w.is_negative() as u32) << 3
368     }
369 
370     /// Computes the squared length of `self`.
371     #[doc(alias = "magnitude2")]
372     #[inline]
373     #[must_use]
length_squared(self) -> i32374     pub fn length_squared(self) -> i32 {
375         self.dot(self)
376     }
377 
378     /// Compute the squared euclidean distance between two points in space.
379     #[inline]
380     #[must_use]
distance_squared(self, rhs: Self) -> i32381     pub fn distance_squared(self, rhs: Self) -> i32 {
382         (self - rhs).length_squared()
383     }
384 
385     /// Returns the element-wise quotient of [Euclidean division] of `self` by `rhs`.
386     ///
387     /// # Panics
388     /// This function will panic if any `rhs` element is 0 or the division results in overflow.
389     #[inline]
390     #[must_use]
div_euclid(self, rhs: Self) -> Self391     pub fn div_euclid(self, rhs: Self) -> Self {
392         Self::new(
393             self.x.div_euclid(rhs.x),
394             self.y.div_euclid(rhs.y),
395             self.z.div_euclid(rhs.z),
396             self.w.div_euclid(rhs.w),
397         )
398     }
399 
400     /// Returns the element-wise remainder of [Euclidean division] of `self` by `rhs`.
401     ///
402     /// # Panics
403     /// This function will panic if any `rhs` element is 0 or the division results in overflow.
404     ///
405     /// [Euclidean division]: i32::rem_euclid
406     #[inline]
407     #[must_use]
rem_euclid(self, rhs: Self) -> Self408     pub fn rem_euclid(self, rhs: Self) -> Self {
409         Self::new(
410             self.x.rem_euclid(rhs.x),
411             self.y.rem_euclid(rhs.y),
412             self.z.rem_euclid(rhs.z),
413             self.w.rem_euclid(rhs.w),
414         )
415     }
416 
417     /// Casts all elements of `self` to `f32`.
418     #[inline]
419     #[must_use]
as_vec4(&self) -> crate::Vec4420     pub fn as_vec4(&self) -> crate::Vec4 {
421         crate::Vec4::new(self.x as f32, self.y as f32, self.z as f32, self.w as f32)
422     }
423 
424     /// Casts all elements of `self` to `f64`.
425     #[inline]
426     #[must_use]
as_dvec4(&self) -> crate::DVec4427     pub fn as_dvec4(&self) -> crate::DVec4 {
428         crate::DVec4::new(self.x as f64, self.y as f64, self.z as f64, self.w as f64)
429     }
430 
431     /// Casts all elements of `self` to `i16`.
432     #[inline]
433     #[must_use]
as_i16vec4(&self) -> crate::I16Vec4434     pub fn as_i16vec4(&self) -> crate::I16Vec4 {
435         crate::I16Vec4::new(self.x as i16, self.y as i16, self.z as i16, self.w as i16)
436     }
437 
438     /// Casts all elements of `self` to `u16`.
439     #[inline]
440     #[must_use]
as_u16vec4(&self) -> crate::U16Vec4441     pub fn as_u16vec4(&self) -> crate::U16Vec4 {
442         crate::U16Vec4::new(self.x as u16, self.y as u16, self.z as u16, self.w as u16)
443     }
444 
445     /// Casts all elements of `self` to `u32`.
446     #[inline]
447     #[must_use]
as_uvec4(&self) -> crate::UVec4448     pub fn as_uvec4(&self) -> crate::UVec4 {
449         crate::UVec4::new(self.x as u32, self.y as u32, self.z as u32, self.w as u32)
450     }
451 
452     /// Casts all elements of `self` to `i64`.
453     #[inline]
454     #[must_use]
as_i64vec4(&self) -> crate::I64Vec4455     pub fn as_i64vec4(&self) -> crate::I64Vec4 {
456         crate::I64Vec4::new(self.x as i64, self.y as i64, self.z as i64, self.w as i64)
457     }
458 
459     /// Casts all elements of `self` to `u64`.
460     #[inline]
461     #[must_use]
as_u64vec4(&self) -> crate::U64Vec4462     pub fn as_u64vec4(&self) -> crate::U64Vec4 {
463         crate::U64Vec4::new(self.x as u64, self.y as u64, self.z as u64, self.w as u64)
464     }
465 
466     /// Returns a vector containing the wrapping addition of `self` and `rhs`.
467     ///
468     /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
469     #[inline]
470     #[must_use]
wrapping_add(self, rhs: Self) -> Self471     pub const fn wrapping_add(self, rhs: Self) -> Self {
472         Self {
473             x: self.x.wrapping_add(rhs.x),
474             y: self.y.wrapping_add(rhs.y),
475             z: self.z.wrapping_add(rhs.z),
476             w: self.w.wrapping_add(rhs.w),
477         }
478     }
479 
480     /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
481     ///
482     /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
483     #[inline]
484     #[must_use]
wrapping_sub(self, rhs: Self) -> Self485     pub const fn wrapping_sub(self, rhs: Self) -> Self {
486         Self {
487             x: self.x.wrapping_sub(rhs.x),
488             y: self.y.wrapping_sub(rhs.y),
489             z: self.z.wrapping_sub(rhs.z),
490             w: self.w.wrapping_sub(rhs.w),
491         }
492     }
493 
494     /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
495     ///
496     /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
497     #[inline]
498     #[must_use]
wrapping_mul(self, rhs: Self) -> Self499     pub const fn wrapping_mul(self, rhs: Self) -> Self {
500         Self {
501             x: self.x.wrapping_mul(rhs.x),
502             y: self.y.wrapping_mul(rhs.y),
503             z: self.z.wrapping_mul(rhs.z),
504             w: self.w.wrapping_mul(rhs.w),
505         }
506     }
507 
508     /// Returns a vector containing the wrapping division of `self` and `rhs`.
509     ///
510     /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
511     #[inline]
512     #[must_use]
wrapping_div(self, rhs: Self) -> Self513     pub const fn wrapping_div(self, rhs: Self) -> Self {
514         Self {
515             x: self.x.wrapping_div(rhs.x),
516             y: self.y.wrapping_div(rhs.y),
517             z: self.z.wrapping_div(rhs.z),
518             w: self.w.wrapping_div(rhs.w),
519         }
520     }
521 
522     /// Returns a vector containing the saturating addition of `self` and `rhs`.
523     ///
524     /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
525     #[inline]
526     #[must_use]
saturating_add(self, rhs: Self) -> Self527     pub const fn saturating_add(self, rhs: Self) -> Self {
528         Self {
529             x: self.x.saturating_add(rhs.x),
530             y: self.y.saturating_add(rhs.y),
531             z: self.z.saturating_add(rhs.z),
532             w: self.w.saturating_add(rhs.w),
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]
saturating_sub(self, rhs: Self) -> Self541     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             z: self.z.saturating_sub(rhs.z),
546             w: self.w.saturating_sub(rhs.w),
547         }
548     }
549 
550     /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
551     ///
552     /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
553     #[inline]
554     #[must_use]
saturating_mul(self, rhs: Self) -> Self555     pub const fn saturating_mul(self, rhs: Self) -> Self {
556         Self {
557             x: self.x.saturating_mul(rhs.x),
558             y: self.y.saturating_mul(rhs.y),
559             z: self.z.saturating_mul(rhs.z),
560             w: self.w.saturating_mul(rhs.w),
561         }
562     }
563 
564     /// Returns a vector containing the saturating division of `self` and `rhs`.
565     ///
566     /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
567     #[inline]
568     #[must_use]
saturating_div(self, rhs: Self) -> Self569     pub const fn saturating_div(self, rhs: Self) -> Self {
570         Self {
571             x: self.x.saturating_div(rhs.x),
572             y: self.y.saturating_div(rhs.y),
573             z: self.z.saturating_div(rhs.z),
574             w: self.w.saturating_div(rhs.w),
575         }
576     }
577 }
578 
579 impl Default for IVec4 {
580     #[inline(always)]
default() -> Self581     fn default() -> Self {
582         Self::ZERO
583     }
584 }
585 
586 impl Div<IVec4> for IVec4 {
587     type Output = Self;
588     #[inline]
div(self, rhs: Self) -> Self589     fn div(self, rhs: Self) -> Self {
590         Self {
591             x: self.x.div(rhs.x),
592             y: self.y.div(rhs.y),
593             z: self.z.div(rhs.z),
594             w: self.w.div(rhs.w),
595         }
596     }
597 }
598 
599 impl DivAssign<IVec4> for IVec4 {
600     #[inline]
div_assign(&mut self, rhs: Self)601     fn div_assign(&mut self, rhs: Self) {
602         self.x.div_assign(rhs.x);
603         self.y.div_assign(rhs.y);
604         self.z.div_assign(rhs.z);
605         self.w.div_assign(rhs.w);
606     }
607 }
608 
609 impl Div<i32> for IVec4 {
610     type Output = Self;
611     #[inline]
div(self, rhs: i32) -> Self612     fn div(self, rhs: i32) -> Self {
613         Self {
614             x: self.x.div(rhs),
615             y: self.y.div(rhs),
616             z: self.z.div(rhs),
617             w: self.w.div(rhs),
618         }
619     }
620 }
621 
622 impl DivAssign<i32> for IVec4 {
623     #[inline]
div_assign(&mut self, rhs: i32)624     fn div_assign(&mut self, rhs: i32) {
625         self.x.div_assign(rhs);
626         self.y.div_assign(rhs);
627         self.z.div_assign(rhs);
628         self.w.div_assign(rhs);
629     }
630 }
631 
632 impl Div<IVec4> for i32 {
633     type Output = IVec4;
634     #[inline]
div(self, rhs: IVec4) -> IVec4635     fn div(self, rhs: IVec4) -> IVec4 {
636         IVec4 {
637             x: self.div(rhs.x),
638             y: self.div(rhs.y),
639             z: self.div(rhs.z),
640             w: self.div(rhs.w),
641         }
642     }
643 }
644 
645 impl Mul<IVec4> for IVec4 {
646     type Output = Self;
647     #[inline]
mul(self, rhs: Self) -> Self648     fn mul(self, rhs: Self) -> Self {
649         Self {
650             x: self.x.mul(rhs.x),
651             y: self.y.mul(rhs.y),
652             z: self.z.mul(rhs.z),
653             w: self.w.mul(rhs.w),
654         }
655     }
656 }
657 
658 impl MulAssign<IVec4> for IVec4 {
659     #[inline]
mul_assign(&mut self, rhs: Self)660     fn mul_assign(&mut self, rhs: Self) {
661         self.x.mul_assign(rhs.x);
662         self.y.mul_assign(rhs.y);
663         self.z.mul_assign(rhs.z);
664         self.w.mul_assign(rhs.w);
665     }
666 }
667 
668 impl Mul<i32> for IVec4 {
669     type Output = Self;
670     #[inline]
mul(self, rhs: i32) -> Self671     fn mul(self, rhs: i32) -> Self {
672         Self {
673             x: self.x.mul(rhs),
674             y: self.y.mul(rhs),
675             z: self.z.mul(rhs),
676             w: self.w.mul(rhs),
677         }
678     }
679 }
680 
681 impl MulAssign<i32> for IVec4 {
682     #[inline]
mul_assign(&mut self, rhs: i32)683     fn mul_assign(&mut self, rhs: i32) {
684         self.x.mul_assign(rhs);
685         self.y.mul_assign(rhs);
686         self.z.mul_assign(rhs);
687         self.w.mul_assign(rhs);
688     }
689 }
690 
691 impl Mul<IVec4> for i32 {
692     type Output = IVec4;
693     #[inline]
mul(self, rhs: IVec4) -> IVec4694     fn mul(self, rhs: IVec4) -> IVec4 {
695         IVec4 {
696             x: self.mul(rhs.x),
697             y: self.mul(rhs.y),
698             z: self.mul(rhs.z),
699             w: self.mul(rhs.w),
700         }
701     }
702 }
703 
704 impl Add<IVec4> for IVec4 {
705     type Output = Self;
706     #[inline]
add(self, rhs: Self) -> Self707     fn add(self, rhs: Self) -> Self {
708         Self {
709             x: self.x.add(rhs.x),
710             y: self.y.add(rhs.y),
711             z: self.z.add(rhs.z),
712             w: self.w.add(rhs.w),
713         }
714     }
715 }
716 
717 impl AddAssign<IVec4> for IVec4 {
718     #[inline]
add_assign(&mut self, rhs: Self)719     fn add_assign(&mut self, rhs: Self) {
720         self.x.add_assign(rhs.x);
721         self.y.add_assign(rhs.y);
722         self.z.add_assign(rhs.z);
723         self.w.add_assign(rhs.w);
724     }
725 }
726 
727 impl Add<i32> for IVec4 {
728     type Output = Self;
729     #[inline]
add(self, rhs: i32) -> Self730     fn add(self, rhs: i32) -> Self {
731         Self {
732             x: self.x.add(rhs),
733             y: self.y.add(rhs),
734             z: self.z.add(rhs),
735             w: self.w.add(rhs),
736         }
737     }
738 }
739 
740 impl AddAssign<i32> for IVec4 {
741     #[inline]
add_assign(&mut self, rhs: i32)742     fn add_assign(&mut self, rhs: i32) {
743         self.x.add_assign(rhs);
744         self.y.add_assign(rhs);
745         self.z.add_assign(rhs);
746         self.w.add_assign(rhs);
747     }
748 }
749 
750 impl Add<IVec4> for i32 {
751     type Output = IVec4;
752     #[inline]
add(self, rhs: IVec4) -> IVec4753     fn add(self, rhs: IVec4) -> IVec4 {
754         IVec4 {
755             x: self.add(rhs.x),
756             y: self.add(rhs.y),
757             z: self.add(rhs.z),
758             w: self.add(rhs.w),
759         }
760     }
761 }
762 
763 impl Sub<IVec4> for IVec4 {
764     type Output = Self;
765     #[inline]
sub(self, rhs: Self) -> Self766     fn sub(self, rhs: Self) -> Self {
767         Self {
768             x: self.x.sub(rhs.x),
769             y: self.y.sub(rhs.y),
770             z: self.z.sub(rhs.z),
771             w: self.w.sub(rhs.w),
772         }
773     }
774 }
775 
776 impl SubAssign<IVec4> for IVec4 {
777     #[inline]
sub_assign(&mut self, rhs: IVec4)778     fn sub_assign(&mut self, rhs: IVec4) {
779         self.x.sub_assign(rhs.x);
780         self.y.sub_assign(rhs.y);
781         self.z.sub_assign(rhs.z);
782         self.w.sub_assign(rhs.w);
783     }
784 }
785 
786 impl Sub<i32> for IVec4 {
787     type Output = Self;
788     #[inline]
sub(self, rhs: i32) -> Self789     fn sub(self, rhs: i32) -> Self {
790         Self {
791             x: self.x.sub(rhs),
792             y: self.y.sub(rhs),
793             z: self.z.sub(rhs),
794             w: self.w.sub(rhs),
795         }
796     }
797 }
798 
799 impl SubAssign<i32> for IVec4 {
800     #[inline]
sub_assign(&mut self, rhs: i32)801     fn sub_assign(&mut self, rhs: i32) {
802         self.x.sub_assign(rhs);
803         self.y.sub_assign(rhs);
804         self.z.sub_assign(rhs);
805         self.w.sub_assign(rhs);
806     }
807 }
808 
809 impl Sub<IVec4> for i32 {
810     type Output = IVec4;
811     #[inline]
sub(self, rhs: IVec4) -> IVec4812     fn sub(self, rhs: IVec4) -> IVec4 {
813         IVec4 {
814             x: self.sub(rhs.x),
815             y: self.sub(rhs.y),
816             z: self.sub(rhs.z),
817             w: self.sub(rhs.w),
818         }
819     }
820 }
821 
822 impl Rem<IVec4> for IVec4 {
823     type Output = Self;
824     #[inline]
rem(self, rhs: Self) -> Self825     fn rem(self, rhs: Self) -> Self {
826         Self {
827             x: self.x.rem(rhs.x),
828             y: self.y.rem(rhs.y),
829             z: self.z.rem(rhs.z),
830             w: self.w.rem(rhs.w),
831         }
832     }
833 }
834 
835 impl RemAssign<IVec4> for IVec4 {
836     #[inline]
rem_assign(&mut self, rhs: Self)837     fn rem_assign(&mut self, rhs: Self) {
838         self.x.rem_assign(rhs.x);
839         self.y.rem_assign(rhs.y);
840         self.z.rem_assign(rhs.z);
841         self.w.rem_assign(rhs.w);
842     }
843 }
844 
845 impl Rem<i32> for IVec4 {
846     type Output = Self;
847     #[inline]
rem(self, rhs: i32) -> Self848     fn rem(self, rhs: i32) -> Self {
849         Self {
850             x: self.x.rem(rhs),
851             y: self.y.rem(rhs),
852             z: self.z.rem(rhs),
853             w: self.w.rem(rhs),
854         }
855     }
856 }
857 
858 impl RemAssign<i32> for IVec4 {
859     #[inline]
rem_assign(&mut self, rhs: i32)860     fn rem_assign(&mut self, rhs: i32) {
861         self.x.rem_assign(rhs);
862         self.y.rem_assign(rhs);
863         self.z.rem_assign(rhs);
864         self.w.rem_assign(rhs);
865     }
866 }
867 
868 impl Rem<IVec4> for i32 {
869     type Output = IVec4;
870     #[inline]
rem(self, rhs: IVec4) -> IVec4871     fn rem(self, rhs: IVec4) -> IVec4 {
872         IVec4 {
873             x: self.rem(rhs.x),
874             y: self.rem(rhs.y),
875             z: self.rem(rhs.z),
876             w: self.rem(rhs.w),
877         }
878     }
879 }
880 
881 #[cfg(not(target_arch = "spirv"))]
882 impl AsRef<[i32; 4]> for IVec4 {
883     #[inline]
as_ref(&self) -> &[i32; 4]884     fn as_ref(&self) -> &[i32; 4] {
885         unsafe { &*(self as *const IVec4 as *const [i32; 4]) }
886     }
887 }
888 
889 #[cfg(not(target_arch = "spirv"))]
890 impl AsMut<[i32; 4]> for IVec4 {
891     #[inline]
as_mut(&mut self) -> &mut [i32; 4]892     fn as_mut(&mut self) -> &mut [i32; 4] {
893         unsafe { &mut *(self as *mut IVec4 as *mut [i32; 4]) }
894     }
895 }
896 
897 impl Sum for IVec4 {
898     #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = Self>,899     fn sum<I>(iter: I) -> Self
900     where
901         I: Iterator<Item = Self>,
902     {
903         iter.fold(Self::ZERO, Self::add)
904     }
905 }
906 
907 impl<'a> Sum<&'a Self> for IVec4 {
908     #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,909     fn sum<I>(iter: I) -> Self
910     where
911         I: Iterator<Item = &'a Self>,
912     {
913         iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
914     }
915 }
916 
917 impl Product for IVec4 {
918     #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = Self>,919     fn product<I>(iter: I) -> Self
920     where
921         I: Iterator<Item = Self>,
922     {
923         iter.fold(Self::ONE, Self::mul)
924     }
925 }
926 
927 impl<'a> Product<&'a Self> for IVec4 {
928     #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,929     fn product<I>(iter: I) -> Self
930     where
931         I: Iterator<Item = &'a Self>,
932     {
933         iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
934     }
935 }
936 
937 impl Neg for IVec4 {
938     type Output = Self;
939     #[inline]
neg(self) -> Self940     fn neg(self) -> Self {
941         Self {
942             x: self.x.neg(),
943             y: self.y.neg(),
944             z: self.z.neg(),
945             w: self.w.neg(),
946         }
947     }
948 }
949 
950 impl Not for IVec4 {
951     type Output = Self;
952     #[inline]
not(self) -> Self::Output953     fn not(self) -> Self::Output {
954         Self {
955             x: self.x.not(),
956             y: self.y.not(),
957             z: self.z.not(),
958             w: self.w.not(),
959         }
960     }
961 }
962 
963 impl BitAnd for IVec4 {
964     type Output = Self;
965     #[inline]
bitand(self, rhs: Self) -> Self::Output966     fn bitand(self, rhs: Self) -> Self::Output {
967         Self {
968             x: self.x.bitand(rhs.x),
969             y: self.y.bitand(rhs.y),
970             z: self.z.bitand(rhs.z),
971             w: self.w.bitand(rhs.w),
972         }
973     }
974 }
975 
976 impl BitOr for IVec4 {
977     type Output = Self;
978     #[inline]
bitor(self, rhs: Self) -> Self::Output979     fn bitor(self, rhs: Self) -> Self::Output {
980         Self {
981             x: self.x.bitor(rhs.x),
982             y: self.y.bitor(rhs.y),
983             z: self.z.bitor(rhs.z),
984             w: self.w.bitor(rhs.w),
985         }
986     }
987 }
988 
989 impl BitXor for IVec4 {
990     type Output = Self;
991     #[inline]
bitxor(self, rhs: Self) -> Self::Output992     fn bitxor(self, rhs: Self) -> Self::Output {
993         Self {
994             x: self.x.bitxor(rhs.x),
995             y: self.y.bitxor(rhs.y),
996             z: self.z.bitxor(rhs.z),
997             w: self.w.bitxor(rhs.w),
998         }
999     }
1000 }
1001 
1002 impl BitAnd<i32> for IVec4 {
1003     type Output = Self;
1004     #[inline]
bitand(self, rhs: i32) -> Self::Output1005     fn bitand(self, rhs: i32) -> Self::Output {
1006         Self {
1007             x: self.x.bitand(rhs),
1008             y: self.y.bitand(rhs),
1009             z: self.z.bitand(rhs),
1010             w: self.w.bitand(rhs),
1011         }
1012     }
1013 }
1014 
1015 impl BitOr<i32> for IVec4 {
1016     type Output = Self;
1017     #[inline]
bitor(self, rhs: i32) -> Self::Output1018     fn bitor(self, rhs: i32) -> Self::Output {
1019         Self {
1020             x: self.x.bitor(rhs),
1021             y: self.y.bitor(rhs),
1022             z: self.z.bitor(rhs),
1023             w: self.w.bitor(rhs),
1024         }
1025     }
1026 }
1027 
1028 impl BitXor<i32> for IVec4 {
1029     type Output = Self;
1030     #[inline]
bitxor(self, rhs: i32) -> Self::Output1031     fn bitxor(self, rhs: i32) -> Self::Output {
1032         Self {
1033             x: self.x.bitxor(rhs),
1034             y: self.y.bitxor(rhs),
1035             z: self.z.bitxor(rhs),
1036             w: self.w.bitxor(rhs),
1037         }
1038     }
1039 }
1040 
1041 impl Shl<i8> for IVec4 {
1042     type Output = Self;
1043     #[inline]
shl(self, rhs: i8) -> Self::Output1044     fn shl(self, rhs: i8) -> Self::Output {
1045         Self {
1046             x: self.x.shl(rhs),
1047             y: self.y.shl(rhs),
1048             z: self.z.shl(rhs),
1049             w: self.w.shl(rhs),
1050         }
1051     }
1052 }
1053 
1054 impl Shr<i8> for IVec4 {
1055     type Output = Self;
1056     #[inline]
shr(self, rhs: i8) -> Self::Output1057     fn shr(self, rhs: i8) -> Self::Output {
1058         Self {
1059             x: self.x.shr(rhs),
1060             y: self.y.shr(rhs),
1061             z: self.z.shr(rhs),
1062             w: self.w.shr(rhs),
1063         }
1064     }
1065 }
1066 
1067 impl Shl<i16> for IVec4 {
1068     type Output = Self;
1069     #[inline]
shl(self, rhs: i16) -> Self::Output1070     fn shl(self, rhs: i16) -> Self::Output {
1071         Self {
1072             x: self.x.shl(rhs),
1073             y: self.y.shl(rhs),
1074             z: self.z.shl(rhs),
1075             w: self.w.shl(rhs),
1076         }
1077     }
1078 }
1079 
1080 impl Shr<i16> for IVec4 {
1081     type Output = Self;
1082     #[inline]
shr(self, rhs: i16) -> Self::Output1083     fn shr(self, rhs: i16) -> Self::Output {
1084         Self {
1085             x: self.x.shr(rhs),
1086             y: self.y.shr(rhs),
1087             z: self.z.shr(rhs),
1088             w: self.w.shr(rhs),
1089         }
1090     }
1091 }
1092 
1093 impl Shl<i32> for IVec4 {
1094     type Output = Self;
1095     #[inline]
shl(self, rhs: i32) -> Self::Output1096     fn shl(self, rhs: i32) -> Self::Output {
1097         Self {
1098             x: self.x.shl(rhs),
1099             y: self.y.shl(rhs),
1100             z: self.z.shl(rhs),
1101             w: self.w.shl(rhs),
1102         }
1103     }
1104 }
1105 
1106 impl Shr<i32> for IVec4 {
1107     type Output = Self;
1108     #[inline]
shr(self, rhs: i32) -> Self::Output1109     fn shr(self, rhs: i32) -> Self::Output {
1110         Self {
1111             x: self.x.shr(rhs),
1112             y: self.y.shr(rhs),
1113             z: self.z.shr(rhs),
1114             w: self.w.shr(rhs),
1115         }
1116     }
1117 }
1118 
1119 impl Shl<i64> for IVec4 {
1120     type Output = Self;
1121     #[inline]
shl(self, rhs: i64) -> Self::Output1122     fn shl(self, rhs: i64) -> Self::Output {
1123         Self {
1124             x: self.x.shl(rhs),
1125             y: self.y.shl(rhs),
1126             z: self.z.shl(rhs),
1127             w: self.w.shl(rhs),
1128         }
1129     }
1130 }
1131 
1132 impl Shr<i64> for IVec4 {
1133     type Output = Self;
1134     #[inline]
shr(self, rhs: i64) -> Self::Output1135     fn shr(self, rhs: i64) -> Self::Output {
1136         Self {
1137             x: self.x.shr(rhs),
1138             y: self.y.shr(rhs),
1139             z: self.z.shr(rhs),
1140             w: self.w.shr(rhs),
1141         }
1142     }
1143 }
1144 
1145 impl Shl<u8> for IVec4 {
1146     type Output = Self;
1147     #[inline]
shl(self, rhs: u8) -> Self::Output1148     fn shl(self, rhs: u8) -> Self::Output {
1149         Self {
1150             x: self.x.shl(rhs),
1151             y: self.y.shl(rhs),
1152             z: self.z.shl(rhs),
1153             w: self.w.shl(rhs),
1154         }
1155     }
1156 }
1157 
1158 impl Shr<u8> for IVec4 {
1159     type Output = Self;
1160     #[inline]
shr(self, rhs: u8) -> Self::Output1161     fn shr(self, rhs: u8) -> Self::Output {
1162         Self {
1163             x: self.x.shr(rhs),
1164             y: self.y.shr(rhs),
1165             z: self.z.shr(rhs),
1166             w: self.w.shr(rhs),
1167         }
1168     }
1169 }
1170 
1171 impl Shl<u16> for IVec4 {
1172     type Output = Self;
1173     #[inline]
shl(self, rhs: u16) -> Self::Output1174     fn shl(self, rhs: u16) -> Self::Output {
1175         Self {
1176             x: self.x.shl(rhs),
1177             y: self.y.shl(rhs),
1178             z: self.z.shl(rhs),
1179             w: self.w.shl(rhs),
1180         }
1181     }
1182 }
1183 
1184 impl Shr<u16> for IVec4 {
1185     type Output = Self;
1186     #[inline]
shr(self, rhs: u16) -> Self::Output1187     fn shr(self, rhs: u16) -> Self::Output {
1188         Self {
1189             x: self.x.shr(rhs),
1190             y: self.y.shr(rhs),
1191             z: self.z.shr(rhs),
1192             w: self.w.shr(rhs),
1193         }
1194     }
1195 }
1196 
1197 impl Shl<u32> for IVec4 {
1198     type Output = Self;
1199     #[inline]
shl(self, rhs: u32) -> Self::Output1200     fn shl(self, rhs: u32) -> Self::Output {
1201         Self {
1202             x: self.x.shl(rhs),
1203             y: self.y.shl(rhs),
1204             z: self.z.shl(rhs),
1205             w: self.w.shl(rhs),
1206         }
1207     }
1208 }
1209 
1210 impl Shr<u32> for IVec4 {
1211     type Output = Self;
1212     #[inline]
shr(self, rhs: u32) -> Self::Output1213     fn shr(self, rhs: u32) -> Self::Output {
1214         Self {
1215             x: self.x.shr(rhs),
1216             y: self.y.shr(rhs),
1217             z: self.z.shr(rhs),
1218             w: self.w.shr(rhs),
1219         }
1220     }
1221 }
1222 
1223 impl Shl<u64> for IVec4 {
1224     type Output = Self;
1225     #[inline]
shl(self, rhs: u64) -> Self::Output1226     fn shl(self, rhs: u64) -> Self::Output {
1227         Self {
1228             x: self.x.shl(rhs),
1229             y: self.y.shl(rhs),
1230             z: self.z.shl(rhs),
1231             w: self.w.shl(rhs),
1232         }
1233     }
1234 }
1235 
1236 impl Shr<u64> for IVec4 {
1237     type Output = Self;
1238     #[inline]
shr(self, rhs: u64) -> Self::Output1239     fn shr(self, rhs: u64) -> Self::Output {
1240         Self {
1241             x: self.x.shr(rhs),
1242             y: self.y.shr(rhs),
1243             z: self.z.shr(rhs),
1244             w: self.w.shr(rhs),
1245         }
1246     }
1247 }
1248 
1249 impl Shl<crate::IVec4> for IVec4 {
1250     type Output = Self;
1251     #[inline]
shl(self, rhs: crate::IVec4) -> Self::Output1252     fn shl(self, rhs: crate::IVec4) -> Self::Output {
1253         Self {
1254             x: self.x.shl(rhs.x),
1255             y: self.y.shl(rhs.y),
1256             z: self.z.shl(rhs.z),
1257             w: self.w.shl(rhs.w),
1258         }
1259     }
1260 }
1261 
1262 impl Shr<crate::IVec4> for IVec4 {
1263     type Output = Self;
1264     #[inline]
shr(self, rhs: crate::IVec4) -> Self::Output1265     fn shr(self, rhs: crate::IVec4) -> Self::Output {
1266         Self {
1267             x: self.x.shr(rhs.x),
1268             y: self.y.shr(rhs.y),
1269             z: self.z.shr(rhs.z),
1270             w: self.w.shr(rhs.w),
1271         }
1272     }
1273 }
1274 
1275 impl Shl<crate::UVec4> for IVec4 {
1276     type Output = Self;
1277     #[inline]
shl(self, rhs: crate::UVec4) -> Self::Output1278     fn shl(self, rhs: crate::UVec4) -> Self::Output {
1279         Self {
1280             x: self.x.shl(rhs.x),
1281             y: self.y.shl(rhs.y),
1282             z: self.z.shl(rhs.z),
1283             w: self.w.shl(rhs.w),
1284         }
1285     }
1286 }
1287 
1288 impl Shr<crate::UVec4> for IVec4 {
1289     type Output = Self;
1290     #[inline]
shr(self, rhs: crate::UVec4) -> Self::Output1291     fn shr(self, rhs: crate::UVec4) -> Self::Output {
1292         Self {
1293             x: self.x.shr(rhs.x),
1294             y: self.y.shr(rhs.y),
1295             z: self.z.shr(rhs.z),
1296             w: self.w.shr(rhs.w),
1297         }
1298     }
1299 }
1300 
1301 impl Index<usize> for IVec4 {
1302     type Output = i32;
1303     #[inline]
index(&self, index: usize) -> &Self::Output1304     fn index(&self, index: usize) -> &Self::Output {
1305         match index {
1306             0 => &self.x,
1307             1 => &self.y,
1308             2 => &self.z,
1309             3 => &self.w,
1310             _ => panic!("index out of bounds"),
1311         }
1312     }
1313 }
1314 
1315 impl IndexMut<usize> for IVec4 {
1316     #[inline]
index_mut(&mut self, index: usize) -> &mut Self::Output1317     fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1318         match index {
1319             0 => &mut self.x,
1320             1 => &mut self.y,
1321             2 => &mut self.z,
1322             3 => &mut self.w,
1323             _ => panic!("index out of bounds"),
1324         }
1325     }
1326 }
1327 
1328 #[cfg(not(target_arch = "spirv"))]
1329 impl fmt::Display for IVec4 {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result1330     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1331         write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
1332     }
1333 }
1334 
1335 #[cfg(not(target_arch = "spirv"))]
1336 impl fmt::Debug for IVec4 {
fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result1337     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1338         fmt.debug_tuple(stringify!(IVec4))
1339             .field(&self.x)
1340             .field(&self.y)
1341             .field(&self.z)
1342             .field(&self.w)
1343             .finish()
1344     }
1345 }
1346 
1347 impl From<[i32; 4]> for IVec4 {
1348     #[inline]
from(a: [i32; 4]) -> Self1349     fn from(a: [i32; 4]) -> Self {
1350         Self::new(a[0], a[1], a[2], a[3])
1351     }
1352 }
1353 
1354 impl From<IVec4> for [i32; 4] {
1355     #[inline]
from(v: IVec4) -> Self1356     fn from(v: IVec4) -> Self {
1357         [v.x, v.y, v.z, v.w]
1358     }
1359 }
1360 
1361 impl From<(i32, i32, i32, i32)> for IVec4 {
1362     #[inline]
from(t: (i32, i32, i32, i32)) -> Self1363     fn from(t: (i32, i32, i32, i32)) -> Self {
1364         Self::new(t.0, t.1, t.2, t.3)
1365     }
1366 }
1367 
1368 impl From<IVec4> for (i32, i32, i32, i32) {
1369     #[inline]
from(v: IVec4) -> Self1370     fn from(v: IVec4) -> Self {
1371         (v.x, v.y, v.z, v.w)
1372     }
1373 }
1374 
1375 impl From<(IVec3, i32)> for IVec4 {
1376     #[inline]
from((v, w): (IVec3, i32)) -> Self1377     fn from((v, w): (IVec3, i32)) -> Self {
1378         Self::new(v.x, v.y, v.z, w)
1379     }
1380 }
1381 
1382 impl From<(i32, IVec3)> for IVec4 {
1383     #[inline]
from((x, v): (i32, IVec3)) -> Self1384     fn from((x, v): (i32, IVec3)) -> Self {
1385         Self::new(x, v.x, v.y, v.z)
1386     }
1387 }
1388 
1389 impl From<(IVec2, i32, i32)> for IVec4 {
1390     #[inline]
from((v, z, w): (IVec2, i32, i32)) -> Self1391     fn from((v, z, w): (IVec2, i32, i32)) -> Self {
1392         Self::new(v.x, v.y, z, w)
1393     }
1394 }
1395 
1396 impl From<(IVec2, IVec2)> for IVec4 {
1397     #[inline]
from((v, u): (IVec2, IVec2)) -> Self1398     fn from((v, u): (IVec2, IVec2)) -> Self {
1399         Self::new(v.x, v.y, u.x, u.y)
1400     }
1401 }
1402 
1403 impl From<I16Vec4> for IVec4 {
1404     #[inline]
from(v: I16Vec4) -> Self1405     fn from(v: I16Vec4) -> Self {
1406         Self::new(
1407             i32::from(v.x),
1408             i32::from(v.y),
1409             i32::from(v.z),
1410             i32::from(v.w),
1411         )
1412     }
1413 }
1414 
1415 impl From<U16Vec4> for IVec4 {
1416     #[inline]
from(v: U16Vec4) -> Self1417     fn from(v: U16Vec4) -> Self {
1418         Self::new(
1419             i32::from(v.x),
1420             i32::from(v.y),
1421             i32::from(v.z),
1422             i32::from(v.w),
1423         )
1424     }
1425 }
1426 
1427 impl TryFrom<UVec4> for IVec4 {
1428     type Error = core::num::TryFromIntError;
1429 
1430     #[inline]
try_from(v: UVec4) -> Result<Self, Self::Error>1431     fn try_from(v: UVec4) -> Result<Self, Self::Error> {
1432         Ok(Self::new(
1433             i32::try_from(v.x)?,
1434             i32::try_from(v.y)?,
1435             i32::try_from(v.z)?,
1436             i32::try_from(v.w)?,
1437         ))
1438     }
1439 }
1440 
1441 impl TryFrom<I64Vec4> for IVec4 {
1442     type Error = core::num::TryFromIntError;
1443 
1444     #[inline]
try_from(v: I64Vec4) -> Result<Self, Self::Error>1445     fn try_from(v: I64Vec4) -> Result<Self, Self::Error> {
1446         Ok(Self::new(
1447             i32::try_from(v.x)?,
1448             i32::try_from(v.y)?,
1449             i32::try_from(v.z)?,
1450             i32::try_from(v.w)?,
1451         ))
1452     }
1453 }
1454 
1455 impl TryFrom<U64Vec4> for IVec4 {
1456     type Error = core::num::TryFromIntError;
1457 
1458     #[inline]
try_from(v: U64Vec4) -> Result<Self, Self::Error>1459     fn try_from(v: U64Vec4) -> Result<Self, Self::Error> {
1460         Ok(Self::new(
1461             i32::try_from(v.x)?,
1462             i32::try_from(v.y)?,
1463             i32::try_from(v.z)?,
1464             i32::try_from(v.w)?,
1465         ))
1466     }
1467 }
1468