glam/u32/
uvec4.rs

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