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