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