Skip to main content

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