• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Generated from vec.rs.tera template. Edit the template, not the generated file.
2 
3 #[cfg(not(feature = "scalar-math"))]
4 use crate::BVec4A;
5 use crate::{BVec4, I16Vec4, I64Vec4, I8Vec4, IVec4, U16Vec2, U16Vec3, U64Vec4, U8Vec4, UVec4};
6 
7 use core::fmt;
8 use core::iter::{Product, Sum};
9 use core::{f32, ops::*};
10 
11 /// Creates a 4-dimensional vector.
12 #[inline(always)]
13 #[must_use]
u16vec4(x: u16, y: u16, z: u16, w: u16) -> U16Vec414 pub const fn u16vec4(x: u16, y: u16, z: u16, w: u16) -> U16Vec4 {
15     U16Vec4::new(x, y, z, w)
16 }
17 
18 /// A 4-dimensional vector.
19 #[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
20 #[derive(Clone, Copy, PartialEq, Eq)]
21 #[cfg_attr(feature = "cuda", repr(align(8)))]
22 #[cfg_attr(not(target_arch = "spirv"), repr(C))]
23 #[cfg_attr(target_arch = "spirv", repr(simd))]
24 pub struct U16Vec4 {
25     pub x: u16,
26     pub y: u16,
27     pub z: u16,
28     pub w: u16,
29 }
30 
31 impl U16Vec4 {
32     /// All zeroes.
33     pub const ZERO: Self = Self::splat(0);
34 
35     /// All ones.
36     pub const ONE: Self = Self::splat(1);
37 
38     /// All `u16::MIN`.
39     pub const MIN: Self = Self::splat(u16::MIN);
40 
41     /// All `u16::MAX`.
42     pub const MAX: Self = Self::splat(u16::MAX);
43 
44     /// A unit vector pointing along the positive X axis.
45     pub const X: Self = Self::new(1, 0, 0, 0);
46 
47     /// A unit vector pointing along the positive Y axis.
48     pub const Y: Self = Self::new(0, 1, 0, 0);
49 
50     /// A unit vector pointing along the positive Z axis.
51     pub const Z: Self = Self::new(0, 0, 1, 0);
52 
53     /// A unit vector pointing along the positive W axis.
54     pub const W: Self = Self::new(0, 0, 0, 1);
55 
56     /// The unit axes.
57     pub const AXES: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
58 
59     /// Creates a new vector.
60     #[inline(always)]
61     #[must_use]
new(x: u16, y: u16, z: u16, w: u16) -> Self62     pub const fn new(x: u16, y: u16, z: u16, w: u16) -> Self {
63         Self { x, y, z, w }
64     }
65 
66     /// Creates a vector with all elements set to `v`.
67     #[inline]
68     #[must_use]
splat(v: u16) -> Self69     pub const fn splat(v: u16) -> Self {
70         Self {
71             x: v,
72 
73             y: v,
74 
75             z: v,
76 
77             w: v,
78         }
79     }
80 
81     /// Returns a vector containing each element of `self` modified by a mapping function `f`.
82     #[inline]
83     #[must_use]
map<F>(self, f: F) -> Self where F: Fn(u16) -> u16,84     pub fn map<F>(self, f: F) -> Self
85     where
86         F: Fn(u16) -> u16,
87     {
88         Self::new(f(self.x), f(self.y), f(self.z), f(self.w))
89     }
90 
91     /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
92     /// for each element of `self`.
93     ///
94     /// A true element in the mask uses the corresponding element from `if_true`, and false
95     /// uses the element from `if_false`.
96     #[inline]
97     #[must_use]
select(mask: BVec4, if_true: Self, if_false: Self) -> Self98     pub fn select(mask: BVec4, if_true: Self, if_false: Self) -> Self {
99         Self {
100             x: if mask.test(0) { if_true.x } else { if_false.x },
101             y: if mask.test(1) { if_true.y } else { if_false.y },
102             z: if mask.test(2) { if_true.z } else { if_false.z },
103             w: if mask.test(3) { if_true.w } else { if_false.w },
104         }
105     }
106 
107     /// Creates a new vector from an array.
108     #[inline]
109     #[must_use]
from_array(a: [u16; 4]) -> Self110     pub const fn from_array(a: [u16; 4]) -> Self {
111         Self::new(a[0], a[1], a[2], a[3])
112     }
113 
114     /// `[x, y, z, w]`
115     #[inline]
116     #[must_use]
to_array(&self) -> [u16; 4]117     pub const fn to_array(&self) -> [u16; 4] {
118         [self.x, self.y, self.z, self.w]
119     }
120 
121     /// Creates a vector from the first 4 values in `slice`.
122     ///
123     /// # Panics
124     ///
125     /// Panics if `slice` is less than 4 elements long.
126     #[inline]
127     #[must_use]
from_slice(slice: &[u16]) -> Self128     pub const fn from_slice(slice: &[u16]) -> Self {
129         assert!(slice.len() >= 4);
130         Self::new(slice[0], slice[1], slice[2], slice[3])
131     }
132 
133     /// Writes the elements of `self` to the first 4 elements in `slice`.
134     ///
135     /// # Panics
136     ///
137     /// Panics if `slice` is less than 4 elements long.
138     #[inline]
write_to_slice(self, slice: &mut [u16])139     pub fn write_to_slice(self, slice: &mut [u16]) {
140         slice[..4].copy_from_slice(&self.to_array());
141     }
142 
143     /// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`.
144     ///
145     /// Truncation to [`U16Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()].
146     #[inline]
147     #[must_use]
truncate(self) -> U16Vec3148     pub fn truncate(self) -> U16Vec3 {
149         use crate::swizzles::Vec4Swizzles;
150         self.xyz()
151     }
152 
153     /// Creates a 4D vector from `self` with the given value of `x`.
154     #[inline]
155     #[must_use]
with_x(mut self, x: u16) -> Self156     pub fn with_x(mut self, x: u16) -> Self {
157         self.x = x;
158         self
159     }
160 
161     /// Creates a 4D vector from `self` with the given value of `y`.
162     #[inline]
163     #[must_use]
with_y(mut self, y: u16) -> Self164     pub fn with_y(mut self, y: u16) -> Self {
165         self.y = y;
166         self
167     }
168 
169     /// Creates a 4D vector from `self` with the given value of `z`.
170     #[inline]
171     #[must_use]
with_z(mut self, z: u16) -> Self172     pub fn with_z(mut self, z: u16) -> Self {
173         self.z = z;
174         self
175     }
176 
177     /// Creates a 4D vector from `self` with the given value of `w`.
178     #[inline]
179     #[must_use]
with_w(mut self, w: u16) -> Self180     pub fn with_w(mut self, w: u16) -> Self {
181         self.w = w;
182         self
183     }
184 
185     /// Computes the dot product of `self` and `rhs`.
186     #[inline]
187     #[must_use]
dot(self, rhs: Self) -> u16188     pub fn dot(self, rhs: Self) -> u16 {
189         (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) + (self.w * rhs.w)
190     }
191 
192     /// Returns a vector where every component is the dot product of `self` and `rhs`.
193     #[inline]
194     #[must_use]
dot_into_vec(self, rhs: Self) -> Self195     pub fn dot_into_vec(self, rhs: Self) -> Self {
196         Self::splat(self.dot(rhs))
197     }
198 
199     /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
200     ///
201     /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
202     #[inline]
203     #[must_use]
min(self, rhs: Self) -> Self204     pub fn min(self, rhs: Self) -> Self {
205         Self {
206             x: self.x.min(rhs.x),
207             y: self.y.min(rhs.y),
208             z: self.z.min(rhs.z),
209             w: self.w.min(rhs.w),
210         }
211     }
212 
213     /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
214     ///
215     /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
216     #[inline]
217     #[must_use]
max(self, rhs: Self) -> Self218     pub fn max(self, rhs: Self) -> Self {
219         Self {
220             x: self.x.max(rhs.x),
221             y: self.y.max(rhs.y),
222             z: self.z.max(rhs.z),
223             w: self.w.max(rhs.w),
224         }
225     }
226 
227     /// Component-wise clamping of values, similar to [`u16::clamp`].
228     ///
229     /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
230     ///
231     /// # Panics
232     ///
233     /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
234     #[inline]
235     #[must_use]
clamp(self, min: Self, max: Self) -> Self236     pub fn clamp(self, min: Self, max: Self) -> Self {
237         glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
238         self.max(min).min(max)
239     }
240 
241     /// Returns the horizontal minimum of `self`.
242     ///
243     /// In other words this computes `min(x, y, ..)`.
244     #[inline]
245     #[must_use]
min_element(self) -> u16246     pub fn min_element(self) -> u16 {
247         self.x.min(self.y.min(self.z.min(self.w)))
248     }
249 
250     /// Returns the horizontal maximum of `self`.
251     ///
252     /// In other words this computes `max(x, y, ..)`.
253     #[inline]
254     #[must_use]
max_element(self) -> u16255     pub fn max_element(self) -> u16 {
256         self.x.max(self.y.max(self.z.max(self.w)))
257     }
258 
259     /// Returns the sum of all elements of `self`.
260     ///
261     /// In other words, this computes `self.x + self.y + ..`.
262     #[inline]
263     #[must_use]
element_sum(self) -> u16264     pub fn element_sum(self) -> u16 {
265         self.x + self.y + self.z + self.w
266     }
267 
268     /// Returns the product of all elements of `self`.
269     ///
270     /// In other words, this computes `self.x * self.y * ..`.
271     #[inline]
272     #[must_use]
element_product(self) -> u16273     pub fn element_product(self) -> u16 {
274         self.x * self.y * self.z * self.w
275     }
276 
277     /// Returns a vector mask containing the result of a `==` comparison for each element of
278     /// `self` and `rhs`.
279     ///
280     /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
281     /// elements.
282     #[inline]
283     #[must_use]
cmpeq(self, rhs: Self) -> BVec4284     pub fn cmpeq(self, rhs: Self) -> BVec4 {
285         BVec4::new(
286             self.x.eq(&rhs.x),
287             self.y.eq(&rhs.y),
288             self.z.eq(&rhs.z),
289             self.w.eq(&rhs.w),
290         )
291     }
292 
293     /// Returns a vector mask containing the result of a `!=` comparison for each element of
294     /// `self` and `rhs`.
295     ///
296     /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
297     /// elements.
298     #[inline]
299     #[must_use]
cmpne(self, rhs: Self) -> BVec4300     pub fn cmpne(self, rhs: Self) -> BVec4 {
301         BVec4::new(
302             self.x.ne(&rhs.x),
303             self.y.ne(&rhs.y),
304             self.z.ne(&rhs.z),
305             self.w.ne(&rhs.w),
306         )
307     }
308 
309     /// Returns a vector mask containing the result of a `>=` comparison for each element of
310     /// `self` and `rhs`.
311     ///
312     /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
313     /// elements.
314     #[inline]
315     #[must_use]
cmpge(self, rhs: Self) -> BVec4316     pub fn cmpge(self, rhs: Self) -> BVec4 {
317         BVec4::new(
318             self.x.ge(&rhs.x),
319             self.y.ge(&rhs.y),
320             self.z.ge(&rhs.z),
321             self.w.ge(&rhs.w),
322         )
323     }
324 
325     /// Returns a vector mask containing the result of a `>` comparison for each element of
326     /// `self` and `rhs`.
327     ///
328     /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
329     /// elements.
330     #[inline]
331     #[must_use]
cmpgt(self, rhs: Self) -> BVec4332     pub fn cmpgt(self, rhs: Self) -> BVec4 {
333         BVec4::new(
334             self.x.gt(&rhs.x),
335             self.y.gt(&rhs.y),
336             self.z.gt(&rhs.z),
337             self.w.gt(&rhs.w),
338         )
339     }
340 
341     /// Returns a vector mask containing the result of a `<=` comparison for each element of
342     /// `self` and `rhs`.
343     ///
344     /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
345     /// elements.
346     #[inline]
347     #[must_use]
cmple(self, rhs: Self) -> BVec4348     pub fn cmple(self, rhs: Self) -> BVec4 {
349         BVec4::new(
350             self.x.le(&rhs.x),
351             self.y.le(&rhs.y),
352             self.z.le(&rhs.z),
353             self.w.le(&rhs.w),
354         )
355     }
356 
357     /// Returns a vector mask containing the result of a `<` comparison for each element of
358     /// `self` and `rhs`.
359     ///
360     /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
361     /// elements.
362     #[inline]
363     #[must_use]
cmplt(self, rhs: Self) -> BVec4364     pub fn cmplt(self, rhs: Self) -> BVec4 {
365         BVec4::new(
366             self.x.lt(&rhs.x),
367             self.y.lt(&rhs.y),
368             self.z.lt(&rhs.z),
369             self.w.lt(&rhs.w),
370         )
371     }
372 
373     /// Computes the squared length of `self`.
374     #[doc(alias = "magnitude2")]
375     #[inline]
376     #[must_use]
length_squared(self) -> u16377     pub fn length_squared(self) -> u16 {
378         self.dot(self)
379     }
380 
381     /// Computes the [manhattan distance] between two points.
382     ///
383     /// # Overflow
384     /// This method may overflow if the result is greater than [`u16::MAX`].
385     ///
386     /// See also [`checked_manhattan_distance`][U16Vec4::checked_manhattan_distance].
387     ///
388     /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
389     #[inline]
390     #[must_use]
manhattan_distance(self, other: Self) -> u16391     pub fn manhattan_distance(self, other: Self) -> u16 {
392         self.x.abs_diff(other.x)
393             + self.y.abs_diff(other.y)
394             + self.z.abs_diff(other.z)
395             + self.w.abs_diff(other.w)
396     }
397 
398     /// Computes the [manhattan distance] between two points.
399     ///
400     /// This will returns [`None`] if the result is greater than [`u16::MAX`].
401     ///
402     /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
403     #[inline]
404     #[must_use]
checked_manhattan_distance(self, other: Self) -> Option<u16>405     pub fn checked_manhattan_distance(self, other: Self) -> Option<u16> {
406         let d = self.x.abs_diff(other.x);
407         let d = d.checked_add(self.y.abs_diff(other.y))?;
408         let d = d.checked_add(self.z.abs_diff(other.z))?;
409         d.checked_add(self.w.abs_diff(other.w))
410     }
411 
412     /// Computes the [chebyshev distance] between two points.
413     ///
414     /// [chebyshev distance]: https://en.wikipedia.org/wiki/Chebyshev_distance
415     #[inline]
416     #[must_use]
chebyshev_distance(self, other: Self) -> u16417     pub fn chebyshev_distance(self, other: Self) -> u16 {
418         // Note: the compiler will eventually optimize out the loop
419         [
420             self.x.abs_diff(other.x),
421             self.y.abs_diff(other.y),
422             self.z.abs_diff(other.z),
423             self.w.abs_diff(other.w),
424         ]
425         .into_iter()
426         .max()
427         .unwrap()
428     }
429 
430     /// Casts all elements of `self` to `f32`.
431     #[inline]
432     #[must_use]
as_vec4(&self) -> crate::Vec4433     pub fn as_vec4(&self) -> crate::Vec4 {
434         crate::Vec4::new(self.x as f32, self.y as f32, self.z as f32, self.w as f32)
435     }
436 
437     /// Casts all elements of `self` to `f64`.
438     #[inline]
439     #[must_use]
as_dvec4(&self) -> crate::DVec4440     pub fn as_dvec4(&self) -> crate::DVec4 {
441         crate::DVec4::new(self.x as f64, self.y as f64, self.z as f64, self.w as f64)
442     }
443 
444     /// Casts all elements of `self` to `i8`.
445     #[inline]
446     #[must_use]
as_i8vec4(&self) -> crate::I8Vec4447     pub fn as_i8vec4(&self) -> crate::I8Vec4 {
448         crate::I8Vec4::new(self.x as i8, self.y as i8, self.z as i8, self.w as i8)
449     }
450 
451     /// Casts all elements of `self` to `u8`.
452     #[inline]
453     #[must_use]
as_u8vec4(&self) -> crate::U8Vec4454     pub fn as_u8vec4(&self) -> crate::U8Vec4 {
455         crate::U8Vec4::new(self.x as u8, self.y as u8, self.z as u8, self.w as u8)
456     }
457 
458     /// Casts all elements of `self` to `i16`.
459     #[inline]
460     #[must_use]
as_i16vec4(&self) -> crate::I16Vec4461     pub fn as_i16vec4(&self) -> crate::I16Vec4 {
462         crate::I16Vec4::new(self.x as i16, self.y as i16, self.z as i16, self.w as i16)
463     }
464 
465     /// Casts all elements of `self` to `i32`.
466     #[inline]
467     #[must_use]
as_ivec4(&self) -> crate::IVec4468     pub fn as_ivec4(&self) -> crate::IVec4 {
469         crate::IVec4::new(self.x as i32, self.y as i32, self.z as i32, self.w as i32)
470     }
471 
472     /// Casts all elements of `self` to `u32`.
473     #[inline]
474     #[must_use]
as_uvec4(&self) -> crate::UVec4475     pub fn as_uvec4(&self) -> crate::UVec4 {
476         crate::UVec4::new(self.x as u32, self.y as u32, self.z as u32, self.w as u32)
477     }
478 
479     /// Casts all elements of `self` to `i64`.
480     #[inline]
481     #[must_use]
as_i64vec4(&self) -> crate::I64Vec4482     pub fn as_i64vec4(&self) -> crate::I64Vec4 {
483         crate::I64Vec4::new(self.x as i64, self.y as i64, self.z as i64, self.w as i64)
484     }
485 
486     /// Casts all elements of `self` to `u64`.
487     #[inline]
488     #[must_use]
as_u64vec4(&self) -> crate::U64Vec4489     pub fn as_u64vec4(&self) -> crate::U64Vec4 {
490         crate::U64Vec4::new(self.x as u64, self.y as u64, self.z as u64, self.w as u64)
491     }
492 
493     /// Returns a vector containing the wrapping addition of `self` and `rhs`.
494     ///
495     /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
496     #[inline]
497     #[must_use]
checked_add(self, rhs: Self) -> Option<Self>498     pub const fn checked_add(self, rhs: Self) -> Option<Self> {
499         let x = match self.x.checked_add(rhs.x) {
500             Some(v) => v,
501             None => return None,
502         };
503         let y = match self.y.checked_add(rhs.y) {
504             Some(v) => v,
505             None => return None,
506         };
507         let z = match self.z.checked_add(rhs.z) {
508             Some(v) => v,
509             None => return None,
510         };
511         let w = match self.w.checked_add(rhs.w) {
512             Some(v) => v,
513             None => return None,
514         };
515 
516         Some(Self { x, y, z, w })
517     }
518 
519     /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
520     ///
521     /// In other words this computes `Some([self.x - rhs.x, self.y - rhs.y, ..])` but returns `None` on any overflow.
522     #[inline]
523     #[must_use]
checked_sub(self, rhs: Self) -> Option<Self>524     pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
525         let x = match self.x.checked_sub(rhs.x) {
526             Some(v) => v,
527             None => return None,
528         };
529         let y = match self.y.checked_sub(rhs.y) {
530             Some(v) => v,
531             None => return None,
532         };
533         let z = match self.z.checked_sub(rhs.z) {
534             Some(v) => v,
535             None => return None,
536         };
537         let w = match self.w.checked_sub(rhs.w) {
538             Some(v) => v,
539             None => return None,
540         };
541 
542         Some(Self { x, y, z, w })
543     }
544 
545     /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
546     ///
547     /// In other words this computes `Some([self.x * rhs.x, self.y * rhs.y, ..])` but returns `None` on any overflow.
548     #[inline]
549     #[must_use]
checked_mul(self, rhs: Self) -> Option<Self>550     pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
551         let x = match self.x.checked_mul(rhs.x) {
552             Some(v) => v,
553             None => return None,
554         };
555         let y = match self.y.checked_mul(rhs.y) {
556             Some(v) => v,
557             None => return None,
558         };
559         let z = match self.z.checked_mul(rhs.z) {
560             Some(v) => v,
561             None => return None,
562         };
563         let w = match self.w.checked_mul(rhs.w) {
564             Some(v) => v,
565             None => return None,
566         };
567 
568         Some(Self { x, y, z, w })
569     }
570 
571     /// Returns a vector containing the wrapping division of `self` and `rhs`.
572     ///
573     /// In other words this computes `Some([self.x / rhs.x, self.y / rhs.y, ..])` but returns `None` on any division by zero.
574     #[inline]
575     #[must_use]
checked_div(self, rhs: Self) -> Option<Self>576     pub const fn checked_div(self, rhs: Self) -> Option<Self> {
577         let x = match self.x.checked_div(rhs.x) {
578             Some(v) => v,
579             None => return None,
580         };
581         let y = match self.y.checked_div(rhs.y) {
582             Some(v) => v,
583             None => return None,
584         };
585         let z = match self.z.checked_div(rhs.z) {
586             Some(v) => v,
587             None => return None,
588         };
589         let w = match self.w.checked_div(rhs.w) {
590             Some(v) => v,
591             None => return None,
592         };
593 
594         Some(Self { x, y, z, w })
595     }
596 
597     /// Returns a vector containing the wrapping addition of `self` and `rhs`.
598     ///
599     /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
600     #[inline]
601     #[must_use]
wrapping_add(self, rhs: Self) -> Self602     pub const fn wrapping_add(self, rhs: Self) -> Self {
603         Self {
604             x: self.x.wrapping_add(rhs.x),
605             y: self.y.wrapping_add(rhs.y),
606             z: self.z.wrapping_add(rhs.z),
607             w: self.w.wrapping_add(rhs.w),
608         }
609     }
610 
611     /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
612     ///
613     /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
614     #[inline]
615     #[must_use]
wrapping_sub(self, rhs: Self) -> Self616     pub const fn wrapping_sub(self, rhs: Self) -> Self {
617         Self {
618             x: self.x.wrapping_sub(rhs.x),
619             y: self.y.wrapping_sub(rhs.y),
620             z: self.z.wrapping_sub(rhs.z),
621             w: self.w.wrapping_sub(rhs.w),
622         }
623     }
624 
625     /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
626     ///
627     /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
628     #[inline]
629     #[must_use]
wrapping_mul(self, rhs: Self) -> Self630     pub const fn wrapping_mul(self, rhs: Self) -> Self {
631         Self {
632             x: self.x.wrapping_mul(rhs.x),
633             y: self.y.wrapping_mul(rhs.y),
634             z: self.z.wrapping_mul(rhs.z),
635             w: self.w.wrapping_mul(rhs.w),
636         }
637     }
638 
639     /// Returns a vector containing the wrapping division of `self` and `rhs`.
640     ///
641     /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
642     #[inline]
643     #[must_use]
wrapping_div(self, rhs: Self) -> Self644     pub const fn wrapping_div(self, rhs: Self) -> Self {
645         Self {
646             x: self.x.wrapping_div(rhs.x),
647             y: self.y.wrapping_div(rhs.y),
648             z: self.z.wrapping_div(rhs.z),
649             w: self.w.wrapping_div(rhs.w),
650         }
651     }
652 
653     /// Returns a vector containing the saturating addition of `self` and `rhs`.
654     ///
655     /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
656     #[inline]
657     #[must_use]
saturating_add(self, rhs: Self) -> Self658     pub const fn saturating_add(self, rhs: Self) -> Self {
659         Self {
660             x: self.x.saturating_add(rhs.x),
661             y: self.y.saturating_add(rhs.y),
662             z: self.z.saturating_add(rhs.z),
663             w: self.w.saturating_add(rhs.w),
664         }
665     }
666 
667     /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
668     ///
669     /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
670     #[inline]
671     #[must_use]
saturating_sub(self, rhs: Self) -> Self672     pub const fn saturating_sub(self, rhs: Self) -> Self {
673         Self {
674             x: self.x.saturating_sub(rhs.x),
675             y: self.y.saturating_sub(rhs.y),
676             z: self.z.saturating_sub(rhs.z),
677             w: self.w.saturating_sub(rhs.w),
678         }
679     }
680 
681     /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
682     ///
683     /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
684     #[inline]
685     #[must_use]
saturating_mul(self, rhs: Self) -> Self686     pub const fn saturating_mul(self, rhs: Self) -> Self {
687         Self {
688             x: self.x.saturating_mul(rhs.x),
689             y: self.y.saturating_mul(rhs.y),
690             z: self.z.saturating_mul(rhs.z),
691             w: self.w.saturating_mul(rhs.w),
692         }
693     }
694 
695     /// Returns a vector containing the saturating division of `self` and `rhs`.
696     ///
697     /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
698     #[inline]
699     #[must_use]
saturating_div(self, rhs: Self) -> Self700     pub const fn saturating_div(self, rhs: Self) -> Self {
701         Self {
702             x: self.x.saturating_div(rhs.x),
703             y: self.y.saturating_div(rhs.y),
704             z: self.z.saturating_div(rhs.z),
705             w: self.w.saturating_div(rhs.w),
706         }
707     }
708 
709     /// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`.
710     ///
711     /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
712     #[inline]
713     #[must_use]
checked_add_signed(self, rhs: I16Vec4) -> Option<Self>714     pub const fn checked_add_signed(self, rhs: I16Vec4) -> Option<Self> {
715         let x = match self.x.checked_add_signed(rhs.x) {
716             Some(v) => v,
717             None => return None,
718         };
719         let y = match self.y.checked_add_signed(rhs.y) {
720             Some(v) => v,
721             None => return None,
722         };
723         let z = match self.z.checked_add_signed(rhs.z) {
724             Some(v) => v,
725             None => return None,
726         };
727         let w = match self.w.checked_add_signed(rhs.w) {
728             Some(v) => v,
729             None => return None,
730         };
731 
732         Some(Self { x, y, z, w })
733     }
734 
735     /// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`.
736     ///
737     /// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`.
738     #[inline]
739     #[must_use]
wrapping_add_signed(self, rhs: I16Vec4) -> Self740     pub const fn wrapping_add_signed(self, rhs: I16Vec4) -> Self {
741         Self {
742             x: self.x.wrapping_add_signed(rhs.x),
743             y: self.y.wrapping_add_signed(rhs.y),
744             z: self.z.wrapping_add_signed(rhs.z),
745             w: self.w.wrapping_add_signed(rhs.w),
746         }
747     }
748 
749     /// Returns a vector containing the saturating addition of `self` and signed vector `rhs`.
750     ///
751     /// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`.
752     #[inline]
753     #[must_use]
saturating_add_signed(self, rhs: I16Vec4) -> Self754     pub const fn saturating_add_signed(self, rhs: I16Vec4) -> Self {
755         Self {
756             x: self.x.saturating_add_signed(rhs.x),
757             y: self.y.saturating_add_signed(rhs.y),
758             z: self.z.saturating_add_signed(rhs.z),
759             w: self.w.saturating_add_signed(rhs.w),
760         }
761     }
762 }
763 
764 impl Default for U16Vec4 {
765     #[inline(always)]
default() -> Self766     fn default() -> Self {
767         Self::ZERO
768     }
769 }
770 
771 impl Div<U16Vec4> for U16Vec4 {
772     type Output = Self;
773     #[inline]
div(self, rhs: Self) -> Self774     fn div(self, rhs: Self) -> Self {
775         Self {
776             x: self.x.div(rhs.x),
777             y: self.y.div(rhs.y),
778             z: self.z.div(rhs.z),
779             w: self.w.div(rhs.w),
780         }
781     }
782 }
783 
784 impl Div<&U16Vec4> for U16Vec4 {
785     type Output = U16Vec4;
786     #[inline]
div(self, rhs: &U16Vec4) -> U16Vec4787     fn div(self, rhs: &U16Vec4) -> U16Vec4 {
788         self.div(*rhs)
789     }
790 }
791 
792 impl Div<&U16Vec4> for &U16Vec4 {
793     type Output = U16Vec4;
794     #[inline]
div(self, rhs: &U16Vec4) -> U16Vec4795     fn div(self, rhs: &U16Vec4) -> U16Vec4 {
796         (*self).div(*rhs)
797     }
798 }
799 
800 impl Div<U16Vec4> for &U16Vec4 {
801     type Output = U16Vec4;
802     #[inline]
div(self, rhs: U16Vec4) -> U16Vec4803     fn div(self, rhs: U16Vec4) -> U16Vec4 {
804         (*self).div(rhs)
805     }
806 }
807 
808 impl DivAssign<U16Vec4> for U16Vec4 {
809     #[inline]
div_assign(&mut self, rhs: Self)810     fn div_assign(&mut self, rhs: Self) {
811         self.x.div_assign(rhs.x);
812         self.y.div_assign(rhs.y);
813         self.z.div_assign(rhs.z);
814         self.w.div_assign(rhs.w);
815     }
816 }
817 
818 impl DivAssign<&U16Vec4> for U16Vec4 {
819     #[inline]
div_assign(&mut self, rhs: &U16Vec4)820     fn div_assign(&mut self, rhs: &U16Vec4) {
821         self.div_assign(*rhs)
822     }
823 }
824 
825 impl Div<u16> for U16Vec4 {
826     type Output = Self;
827     #[inline]
div(self, rhs: u16) -> Self828     fn div(self, rhs: u16) -> Self {
829         Self {
830             x: self.x.div(rhs),
831             y: self.y.div(rhs),
832             z: self.z.div(rhs),
833             w: self.w.div(rhs),
834         }
835     }
836 }
837 
838 impl Div<&u16> for U16Vec4 {
839     type Output = U16Vec4;
840     #[inline]
div(self, rhs: &u16) -> U16Vec4841     fn div(self, rhs: &u16) -> U16Vec4 {
842         self.div(*rhs)
843     }
844 }
845 
846 impl Div<&u16> for &U16Vec4 {
847     type Output = U16Vec4;
848     #[inline]
div(self, rhs: &u16) -> U16Vec4849     fn div(self, rhs: &u16) -> U16Vec4 {
850         (*self).div(*rhs)
851     }
852 }
853 
854 impl Div<u16> for &U16Vec4 {
855     type Output = U16Vec4;
856     #[inline]
div(self, rhs: u16) -> U16Vec4857     fn div(self, rhs: u16) -> U16Vec4 {
858         (*self).div(rhs)
859     }
860 }
861 
862 impl DivAssign<u16> for U16Vec4 {
863     #[inline]
div_assign(&mut self, rhs: u16)864     fn div_assign(&mut self, rhs: u16) {
865         self.x.div_assign(rhs);
866         self.y.div_assign(rhs);
867         self.z.div_assign(rhs);
868         self.w.div_assign(rhs);
869     }
870 }
871 
872 impl DivAssign<&u16> for U16Vec4 {
873     #[inline]
div_assign(&mut self, rhs: &u16)874     fn div_assign(&mut self, rhs: &u16) {
875         self.div_assign(*rhs)
876     }
877 }
878 
879 impl Div<U16Vec4> for u16 {
880     type Output = U16Vec4;
881     #[inline]
div(self, rhs: U16Vec4) -> U16Vec4882     fn div(self, rhs: U16Vec4) -> U16Vec4 {
883         U16Vec4 {
884             x: self.div(rhs.x),
885             y: self.div(rhs.y),
886             z: self.div(rhs.z),
887             w: self.div(rhs.w),
888         }
889     }
890 }
891 
892 impl Div<&U16Vec4> for u16 {
893     type Output = U16Vec4;
894     #[inline]
div(self, rhs: &U16Vec4) -> U16Vec4895     fn div(self, rhs: &U16Vec4) -> U16Vec4 {
896         self.div(*rhs)
897     }
898 }
899 
900 impl Div<&U16Vec4> for &u16 {
901     type Output = U16Vec4;
902     #[inline]
div(self, rhs: &U16Vec4) -> U16Vec4903     fn div(self, rhs: &U16Vec4) -> U16Vec4 {
904         (*self).div(*rhs)
905     }
906 }
907 
908 impl Div<U16Vec4> for &u16 {
909     type Output = U16Vec4;
910     #[inline]
div(self, rhs: U16Vec4) -> U16Vec4911     fn div(self, rhs: U16Vec4) -> U16Vec4 {
912         (*self).div(rhs)
913     }
914 }
915 
916 impl Mul<U16Vec4> for U16Vec4 {
917     type Output = Self;
918     #[inline]
mul(self, rhs: Self) -> Self919     fn mul(self, rhs: Self) -> Self {
920         Self {
921             x: self.x.mul(rhs.x),
922             y: self.y.mul(rhs.y),
923             z: self.z.mul(rhs.z),
924             w: self.w.mul(rhs.w),
925         }
926     }
927 }
928 
929 impl Mul<&U16Vec4> for U16Vec4 {
930     type Output = U16Vec4;
931     #[inline]
mul(self, rhs: &U16Vec4) -> U16Vec4932     fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
933         self.mul(*rhs)
934     }
935 }
936 
937 impl Mul<&U16Vec4> for &U16Vec4 {
938     type Output = U16Vec4;
939     #[inline]
mul(self, rhs: &U16Vec4) -> U16Vec4940     fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
941         (*self).mul(*rhs)
942     }
943 }
944 
945 impl Mul<U16Vec4> for &U16Vec4 {
946     type Output = U16Vec4;
947     #[inline]
mul(self, rhs: U16Vec4) -> U16Vec4948     fn mul(self, rhs: U16Vec4) -> U16Vec4 {
949         (*self).mul(rhs)
950     }
951 }
952 
953 impl MulAssign<U16Vec4> for U16Vec4 {
954     #[inline]
mul_assign(&mut self, rhs: Self)955     fn mul_assign(&mut self, rhs: Self) {
956         self.x.mul_assign(rhs.x);
957         self.y.mul_assign(rhs.y);
958         self.z.mul_assign(rhs.z);
959         self.w.mul_assign(rhs.w);
960     }
961 }
962 
963 impl MulAssign<&U16Vec4> for U16Vec4 {
964     #[inline]
mul_assign(&mut self, rhs: &U16Vec4)965     fn mul_assign(&mut self, rhs: &U16Vec4) {
966         self.mul_assign(*rhs)
967     }
968 }
969 
970 impl Mul<u16> for U16Vec4 {
971     type Output = Self;
972     #[inline]
mul(self, rhs: u16) -> Self973     fn mul(self, rhs: u16) -> Self {
974         Self {
975             x: self.x.mul(rhs),
976             y: self.y.mul(rhs),
977             z: self.z.mul(rhs),
978             w: self.w.mul(rhs),
979         }
980     }
981 }
982 
983 impl Mul<&u16> for U16Vec4 {
984     type Output = U16Vec4;
985     #[inline]
mul(self, rhs: &u16) -> U16Vec4986     fn mul(self, rhs: &u16) -> U16Vec4 {
987         self.mul(*rhs)
988     }
989 }
990 
991 impl Mul<&u16> for &U16Vec4 {
992     type Output = U16Vec4;
993     #[inline]
mul(self, rhs: &u16) -> U16Vec4994     fn mul(self, rhs: &u16) -> U16Vec4 {
995         (*self).mul(*rhs)
996     }
997 }
998 
999 impl Mul<u16> for &U16Vec4 {
1000     type Output = U16Vec4;
1001     #[inline]
mul(self, rhs: u16) -> U16Vec41002     fn mul(self, rhs: u16) -> U16Vec4 {
1003         (*self).mul(rhs)
1004     }
1005 }
1006 
1007 impl MulAssign<u16> for U16Vec4 {
1008     #[inline]
mul_assign(&mut self, rhs: u16)1009     fn mul_assign(&mut self, rhs: u16) {
1010         self.x.mul_assign(rhs);
1011         self.y.mul_assign(rhs);
1012         self.z.mul_assign(rhs);
1013         self.w.mul_assign(rhs);
1014     }
1015 }
1016 
1017 impl MulAssign<&u16> for U16Vec4 {
1018     #[inline]
mul_assign(&mut self, rhs: &u16)1019     fn mul_assign(&mut self, rhs: &u16) {
1020         self.mul_assign(*rhs)
1021     }
1022 }
1023 
1024 impl Mul<U16Vec4> for u16 {
1025     type Output = U16Vec4;
1026     #[inline]
mul(self, rhs: U16Vec4) -> U16Vec41027     fn mul(self, rhs: U16Vec4) -> U16Vec4 {
1028         U16Vec4 {
1029             x: self.mul(rhs.x),
1030             y: self.mul(rhs.y),
1031             z: self.mul(rhs.z),
1032             w: self.mul(rhs.w),
1033         }
1034     }
1035 }
1036 
1037 impl Mul<&U16Vec4> for u16 {
1038     type Output = U16Vec4;
1039     #[inline]
mul(self, rhs: &U16Vec4) -> U16Vec41040     fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
1041         self.mul(*rhs)
1042     }
1043 }
1044 
1045 impl Mul<&U16Vec4> for &u16 {
1046     type Output = U16Vec4;
1047     #[inline]
mul(self, rhs: &U16Vec4) -> U16Vec41048     fn mul(self, rhs: &U16Vec4) -> U16Vec4 {
1049         (*self).mul(*rhs)
1050     }
1051 }
1052 
1053 impl Mul<U16Vec4> for &u16 {
1054     type Output = U16Vec4;
1055     #[inline]
mul(self, rhs: U16Vec4) -> U16Vec41056     fn mul(self, rhs: U16Vec4) -> U16Vec4 {
1057         (*self).mul(rhs)
1058     }
1059 }
1060 
1061 impl Add<U16Vec4> for U16Vec4 {
1062     type Output = Self;
1063     #[inline]
add(self, rhs: Self) -> Self1064     fn add(self, rhs: Self) -> Self {
1065         Self {
1066             x: self.x.add(rhs.x),
1067             y: self.y.add(rhs.y),
1068             z: self.z.add(rhs.z),
1069             w: self.w.add(rhs.w),
1070         }
1071     }
1072 }
1073 
1074 impl Add<&U16Vec4> for U16Vec4 {
1075     type Output = U16Vec4;
1076     #[inline]
add(self, rhs: &U16Vec4) -> U16Vec41077     fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1078         self.add(*rhs)
1079     }
1080 }
1081 
1082 impl Add<&U16Vec4> for &U16Vec4 {
1083     type Output = U16Vec4;
1084     #[inline]
add(self, rhs: &U16Vec4) -> U16Vec41085     fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1086         (*self).add(*rhs)
1087     }
1088 }
1089 
1090 impl Add<U16Vec4> for &U16Vec4 {
1091     type Output = U16Vec4;
1092     #[inline]
add(self, rhs: U16Vec4) -> U16Vec41093     fn add(self, rhs: U16Vec4) -> U16Vec4 {
1094         (*self).add(rhs)
1095     }
1096 }
1097 
1098 impl AddAssign<U16Vec4> for U16Vec4 {
1099     #[inline]
add_assign(&mut self, rhs: Self)1100     fn add_assign(&mut self, rhs: Self) {
1101         self.x.add_assign(rhs.x);
1102         self.y.add_assign(rhs.y);
1103         self.z.add_assign(rhs.z);
1104         self.w.add_assign(rhs.w);
1105     }
1106 }
1107 
1108 impl AddAssign<&U16Vec4> for U16Vec4 {
1109     #[inline]
add_assign(&mut self, rhs: &U16Vec4)1110     fn add_assign(&mut self, rhs: &U16Vec4) {
1111         self.add_assign(*rhs)
1112     }
1113 }
1114 
1115 impl Add<u16> for U16Vec4 {
1116     type Output = Self;
1117     #[inline]
add(self, rhs: u16) -> Self1118     fn add(self, rhs: u16) -> Self {
1119         Self {
1120             x: self.x.add(rhs),
1121             y: self.y.add(rhs),
1122             z: self.z.add(rhs),
1123             w: self.w.add(rhs),
1124         }
1125     }
1126 }
1127 
1128 impl Add<&u16> for U16Vec4 {
1129     type Output = U16Vec4;
1130     #[inline]
add(self, rhs: &u16) -> U16Vec41131     fn add(self, rhs: &u16) -> U16Vec4 {
1132         self.add(*rhs)
1133     }
1134 }
1135 
1136 impl Add<&u16> for &U16Vec4 {
1137     type Output = U16Vec4;
1138     #[inline]
add(self, rhs: &u16) -> U16Vec41139     fn add(self, rhs: &u16) -> U16Vec4 {
1140         (*self).add(*rhs)
1141     }
1142 }
1143 
1144 impl Add<u16> for &U16Vec4 {
1145     type Output = U16Vec4;
1146     #[inline]
add(self, rhs: u16) -> U16Vec41147     fn add(self, rhs: u16) -> U16Vec4 {
1148         (*self).add(rhs)
1149     }
1150 }
1151 
1152 impl AddAssign<u16> for U16Vec4 {
1153     #[inline]
add_assign(&mut self, rhs: u16)1154     fn add_assign(&mut self, rhs: u16) {
1155         self.x.add_assign(rhs);
1156         self.y.add_assign(rhs);
1157         self.z.add_assign(rhs);
1158         self.w.add_assign(rhs);
1159     }
1160 }
1161 
1162 impl AddAssign<&u16> for U16Vec4 {
1163     #[inline]
add_assign(&mut self, rhs: &u16)1164     fn add_assign(&mut self, rhs: &u16) {
1165         self.add_assign(*rhs)
1166     }
1167 }
1168 
1169 impl Add<U16Vec4> for u16 {
1170     type Output = U16Vec4;
1171     #[inline]
add(self, rhs: U16Vec4) -> U16Vec41172     fn add(self, rhs: U16Vec4) -> U16Vec4 {
1173         U16Vec4 {
1174             x: self.add(rhs.x),
1175             y: self.add(rhs.y),
1176             z: self.add(rhs.z),
1177             w: self.add(rhs.w),
1178         }
1179     }
1180 }
1181 
1182 impl Add<&U16Vec4> for u16 {
1183     type Output = U16Vec4;
1184     #[inline]
add(self, rhs: &U16Vec4) -> U16Vec41185     fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1186         self.add(*rhs)
1187     }
1188 }
1189 
1190 impl Add<&U16Vec4> for &u16 {
1191     type Output = U16Vec4;
1192     #[inline]
add(self, rhs: &U16Vec4) -> U16Vec41193     fn add(self, rhs: &U16Vec4) -> U16Vec4 {
1194         (*self).add(*rhs)
1195     }
1196 }
1197 
1198 impl Add<U16Vec4> for &u16 {
1199     type Output = U16Vec4;
1200     #[inline]
add(self, rhs: U16Vec4) -> U16Vec41201     fn add(self, rhs: U16Vec4) -> U16Vec4 {
1202         (*self).add(rhs)
1203     }
1204 }
1205 
1206 impl Sub<U16Vec4> for U16Vec4 {
1207     type Output = Self;
1208     #[inline]
sub(self, rhs: Self) -> Self1209     fn sub(self, rhs: Self) -> Self {
1210         Self {
1211             x: self.x.sub(rhs.x),
1212             y: self.y.sub(rhs.y),
1213             z: self.z.sub(rhs.z),
1214             w: self.w.sub(rhs.w),
1215         }
1216     }
1217 }
1218 
1219 impl Sub<&U16Vec4> for U16Vec4 {
1220     type Output = U16Vec4;
1221     #[inline]
sub(self, rhs: &U16Vec4) -> U16Vec41222     fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1223         self.sub(*rhs)
1224     }
1225 }
1226 
1227 impl Sub<&U16Vec4> for &U16Vec4 {
1228     type Output = U16Vec4;
1229     #[inline]
sub(self, rhs: &U16Vec4) -> U16Vec41230     fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1231         (*self).sub(*rhs)
1232     }
1233 }
1234 
1235 impl Sub<U16Vec4> for &U16Vec4 {
1236     type Output = U16Vec4;
1237     #[inline]
sub(self, rhs: U16Vec4) -> U16Vec41238     fn sub(self, rhs: U16Vec4) -> U16Vec4 {
1239         (*self).sub(rhs)
1240     }
1241 }
1242 
1243 impl SubAssign<U16Vec4> for U16Vec4 {
1244     #[inline]
sub_assign(&mut self, rhs: U16Vec4)1245     fn sub_assign(&mut self, rhs: U16Vec4) {
1246         self.x.sub_assign(rhs.x);
1247         self.y.sub_assign(rhs.y);
1248         self.z.sub_assign(rhs.z);
1249         self.w.sub_assign(rhs.w);
1250     }
1251 }
1252 
1253 impl SubAssign<&U16Vec4> for U16Vec4 {
1254     #[inline]
sub_assign(&mut self, rhs: &U16Vec4)1255     fn sub_assign(&mut self, rhs: &U16Vec4) {
1256         self.sub_assign(*rhs)
1257     }
1258 }
1259 
1260 impl Sub<u16> for U16Vec4 {
1261     type Output = Self;
1262     #[inline]
sub(self, rhs: u16) -> Self1263     fn sub(self, rhs: u16) -> Self {
1264         Self {
1265             x: self.x.sub(rhs),
1266             y: self.y.sub(rhs),
1267             z: self.z.sub(rhs),
1268             w: self.w.sub(rhs),
1269         }
1270     }
1271 }
1272 
1273 impl Sub<&u16> for U16Vec4 {
1274     type Output = U16Vec4;
1275     #[inline]
sub(self, rhs: &u16) -> U16Vec41276     fn sub(self, rhs: &u16) -> U16Vec4 {
1277         self.sub(*rhs)
1278     }
1279 }
1280 
1281 impl Sub<&u16> for &U16Vec4 {
1282     type Output = U16Vec4;
1283     #[inline]
sub(self, rhs: &u16) -> U16Vec41284     fn sub(self, rhs: &u16) -> U16Vec4 {
1285         (*self).sub(*rhs)
1286     }
1287 }
1288 
1289 impl Sub<u16> for &U16Vec4 {
1290     type Output = U16Vec4;
1291     #[inline]
sub(self, rhs: u16) -> U16Vec41292     fn sub(self, rhs: u16) -> U16Vec4 {
1293         (*self).sub(rhs)
1294     }
1295 }
1296 
1297 impl SubAssign<u16> for U16Vec4 {
1298     #[inline]
sub_assign(&mut self, rhs: u16)1299     fn sub_assign(&mut self, rhs: u16) {
1300         self.x.sub_assign(rhs);
1301         self.y.sub_assign(rhs);
1302         self.z.sub_assign(rhs);
1303         self.w.sub_assign(rhs);
1304     }
1305 }
1306 
1307 impl SubAssign<&u16> for U16Vec4 {
1308     #[inline]
sub_assign(&mut self, rhs: &u16)1309     fn sub_assign(&mut self, rhs: &u16) {
1310         self.sub_assign(*rhs)
1311     }
1312 }
1313 
1314 impl Sub<U16Vec4> for u16 {
1315     type Output = U16Vec4;
1316     #[inline]
sub(self, rhs: U16Vec4) -> U16Vec41317     fn sub(self, rhs: U16Vec4) -> U16Vec4 {
1318         U16Vec4 {
1319             x: self.sub(rhs.x),
1320             y: self.sub(rhs.y),
1321             z: self.sub(rhs.z),
1322             w: self.sub(rhs.w),
1323         }
1324     }
1325 }
1326 
1327 impl Sub<&U16Vec4> for u16 {
1328     type Output = U16Vec4;
1329     #[inline]
sub(self, rhs: &U16Vec4) -> U16Vec41330     fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1331         self.sub(*rhs)
1332     }
1333 }
1334 
1335 impl Sub<&U16Vec4> for &u16 {
1336     type Output = U16Vec4;
1337     #[inline]
sub(self, rhs: &U16Vec4) -> U16Vec41338     fn sub(self, rhs: &U16Vec4) -> U16Vec4 {
1339         (*self).sub(*rhs)
1340     }
1341 }
1342 
1343 impl Sub<U16Vec4> for &u16 {
1344     type Output = U16Vec4;
1345     #[inline]
sub(self, rhs: U16Vec4) -> U16Vec41346     fn sub(self, rhs: U16Vec4) -> U16Vec4 {
1347         (*self).sub(rhs)
1348     }
1349 }
1350 
1351 impl Rem<U16Vec4> for U16Vec4 {
1352     type Output = Self;
1353     #[inline]
rem(self, rhs: Self) -> Self1354     fn rem(self, rhs: Self) -> Self {
1355         Self {
1356             x: self.x.rem(rhs.x),
1357             y: self.y.rem(rhs.y),
1358             z: self.z.rem(rhs.z),
1359             w: self.w.rem(rhs.w),
1360         }
1361     }
1362 }
1363 
1364 impl Rem<&U16Vec4> for U16Vec4 {
1365     type Output = U16Vec4;
1366     #[inline]
rem(self, rhs: &U16Vec4) -> U16Vec41367     fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1368         self.rem(*rhs)
1369     }
1370 }
1371 
1372 impl Rem<&U16Vec4> for &U16Vec4 {
1373     type Output = U16Vec4;
1374     #[inline]
rem(self, rhs: &U16Vec4) -> U16Vec41375     fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1376         (*self).rem(*rhs)
1377     }
1378 }
1379 
1380 impl Rem<U16Vec4> for &U16Vec4 {
1381     type Output = U16Vec4;
1382     #[inline]
rem(self, rhs: U16Vec4) -> U16Vec41383     fn rem(self, rhs: U16Vec4) -> U16Vec4 {
1384         (*self).rem(rhs)
1385     }
1386 }
1387 
1388 impl RemAssign<U16Vec4> for U16Vec4 {
1389     #[inline]
rem_assign(&mut self, rhs: Self)1390     fn rem_assign(&mut self, rhs: Self) {
1391         self.x.rem_assign(rhs.x);
1392         self.y.rem_assign(rhs.y);
1393         self.z.rem_assign(rhs.z);
1394         self.w.rem_assign(rhs.w);
1395     }
1396 }
1397 
1398 impl RemAssign<&U16Vec4> for U16Vec4 {
1399     #[inline]
rem_assign(&mut self, rhs: &U16Vec4)1400     fn rem_assign(&mut self, rhs: &U16Vec4) {
1401         self.rem_assign(*rhs)
1402     }
1403 }
1404 
1405 impl Rem<u16> for U16Vec4 {
1406     type Output = Self;
1407     #[inline]
rem(self, rhs: u16) -> Self1408     fn rem(self, rhs: u16) -> Self {
1409         Self {
1410             x: self.x.rem(rhs),
1411             y: self.y.rem(rhs),
1412             z: self.z.rem(rhs),
1413             w: self.w.rem(rhs),
1414         }
1415     }
1416 }
1417 
1418 impl Rem<&u16> for U16Vec4 {
1419     type Output = U16Vec4;
1420     #[inline]
rem(self, rhs: &u16) -> U16Vec41421     fn rem(self, rhs: &u16) -> U16Vec4 {
1422         self.rem(*rhs)
1423     }
1424 }
1425 
1426 impl Rem<&u16> for &U16Vec4 {
1427     type Output = U16Vec4;
1428     #[inline]
rem(self, rhs: &u16) -> U16Vec41429     fn rem(self, rhs: &u16) -> U16Vec4 {
1430         (*self).rem(*rhs)
1431     }
1432 }
1433 
1434 impl Rem<u16> for &U16Vec4 {
1435     type Output = U16Vec4;
1436     #[inline]
rem(self, rhs: u16) -> U16Vec41437     fn rem(self, rhs: u16) -> U16Vec4 {
1438         (*self).rem(rhs)
1439     }
1440 }
1441 
1442 impl RemAssign<u16> for U16Vec4 {
1443     #[inline]
rem_assign(&mut self, rhs: u16)1444     fn rem_assign(&mut self, rhs: u16) {
1445         self.x.rem_assign(rhs);
1446         self.y.rem_assign(rhs);
1447         self.z.rem_assign(rhs);
1448         self.w.rem_assign(rhs);
1449     }
1450 }
1451 
1452 impl RemAssign<&u16> for U16Vec4 {
1453     #[inline]
rem_assign(&mut self, rhs: &u16)1454     fn rem_assign(&mut self, rhs: &u16) {
1455         self.rem_assign(*rhs)
1456     }
1457 }
1458 
1459 impl Rem<U16Vec4> for u16 {
1460     type Output = U16Vec4;
1461     #[inline]
rem(self, rhs: U16Vec4) -> U16Vec41462     fn rem(self, rhs: U16Vec4) -> U16Vec4 {
1463         U16Vec4 {
1464             x: self.rem(rhs.x),
1465             y: self.rem(rhs.y),
1466             z: self.rem(rhs.z),
1467             w: self.rem(rhs.w),
1468         }
1469     }
1470 }
1471 
1472 impl Rem<&U16Vec4> for u16 {
1473     type Output = U16Vec4;
1474     #[inline]
rem(self, rhs: &U16Vec4) -> U16Vec41475     fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1476         self.rem(*rhs)
1477     }
1478 }
1479 
1480 impl Rem<&U16Vec4> for &u16 {
1481     type Output = U16Vec4;
1482     #[inline]
rem(self, rhs: &U16Vec4) -> U16Vec41483     fn rem(self, rhs: &U16Vec4) -> U16Vec4 {
1484         (*self).rem(*rhs)
1485     }
1486 }
1487 
1488 impl Rem<U16Vec4> for &u16 {
1489     type Output = U16Vec4;
1490     #[inline]
rem(self, rhs: U16Vec4) -> U16Vec41491     fn rem(self, rhs: U16Vec4) -> U16Vec4 {
1492         (*self).rem(rhs)
1493     }
1494 }
1495 
1496 #[cfg(not(target_arch = "spirv"))]
1497 impl AsRef<[u16; 4]> for U16Vec4 {
1498     #[inline]
as_ref(&self) -> &[u16; 4]1499     fn as_ref(&self) -> &[u16; 4] {
1500         unsafe { &*(self as *const U16Vec4 as *const [u16; 4]) }
1501     }
1502 }
1503 
1504 #[cfg(not(target_arch = "spirv"))]
1505 impl AsMut<[u16; 4]> for U16Vec4 {
1506     #[inline]
as_mut(&mut self) -> &mut [u16; 4]1507     fn as_mut(&mut self) -> &mut [u16; 4] {
1508         unsafe { &mut *(self as *mut U16Vec4 as *mut [u16; 4]) }
1509     }
1510 }
1511 
1512 impl Sum for U16Vec4 {
1513     #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = Self>,1514     fn sum<I>(iter: I) -> Self
1515     where
1516         I: Iterator<Item = Self>,
1517     {
1518         iter.fold(Self::ZERO, Self::add)
1519     }
1520 }
1521 
1522 impl<'a> Sum<&'a Self> for U16Vec4 {
1523     #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,1524     fn sum<I>(iter: I) -> Self
1525     where
1526         I: Iterator<Item = &'a Self>,
1527     {
1528         iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1529     }
1530 }
1531 
1532 impl Product for U16Vec4 {
1533     #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = Self>,1534     fn product<I>(iter: I) -> Self
1535     where
1536         I: Iterator<Item = Self>,
1537     {
1538         iter.fold(Self::ONE, Self::mul)
1539     }
1540 }
1541 
1542 impl<'a> Product<&'a Self> for U16Vec4 {
1543     #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,1544     fn product<I>(iter: I) -> Self
1545     where
1546         I: Iterator<Item = &'a Self>,
1547     {
1548         iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1549     }
1550 }
1551 
1552 impl Not for U16Vec4 {
1553     type Output = Self;
1554     #[inline]
not(self) -> Self::Output1555     fn not(self) -> Self::Output {
1556         Self {
1557             x: self.x.not(),
1558             y: self.y.not(),
1559             z: self.z.not(),
1560             w: self.w.not(),
1561         }
1562     }
1563 }
1564 
1565 impl BitAnd for U16Vec4 {
1566     type Output = Self;
1567     #[inline]
bitand(self, rhs: Self) -> Self::Output1568     fn bitand(self, rhs: Self) -> Self::Output {
1569         Self {
1570             x: self.x.bitand(rhs.x),
1571             y: self.y.bitand(rhs.y),
1572             z: self.z.bitand(rhs.z),
1573             w: self.w.bitand(rhs.w),
1574         }
1575     }
1576 }
1577 
1578 impl BitOr for U16Vec4 {
1579     type Output = Self;
1580     #[inline]
bitor(self, rhs: Self) -> Self::Output1581     fn bitor(self, rhs: Self) -> Self::Output {
1582         Self {
1583             x: self.x.bitor(rhs.x),
1584             y: self.y.bitor(rhs.y),
1585             z: self.z.bitor(rhs.z),
1586             w: self.w.bitor(rhs.w),
1587         }
1588     }
1589 }
1590 
1591 impl BitXor for U16Vec4 {
1592     type Output = Self;
1593     #[inline]
bitxor(self, rhs: Self) -> Self::Output1594     fn bitxor(self, rhs: Self) -> Self::Output {
1595         Self {
1596             x: self.x.bitxor(rhs.x),
1597             y: self.y.bitxor(rhs.y),
1598             z: self.z.bitxor(rhs.z),
1599             w: self.w.bitxor(rhs.w),
1600         }
1601     }
1602 }
1603 
1604 impl BitAnd<u16> for U16Vec4 {
1605     type Output = Self;
1606     #[inline]
bitand(self, rhs: u16) -> Self::Output1607     fn bitand(self, rhs: u16) -> Self::Output {
1608         Self {
1609             x: self.x.bitand(rhs),
1610             y: self.y.bitand(rhs),
1611             z: self.z.bitand(rhs),
1612             w: self.w.bitand(rhs),
1613         }
1614     }
1615 }
1616 
1617 impl BitOr<u16> for U16Vec4 {
1618     type Output = Self;
1619     #[inline]
bitor(self, rhs: u16) -> Self::Output1620     fn bitor(self, rhs: u16) -> Self::Output {
1621         Self {
1622             x: self.x.bitor(rhs),
1623             y: self.y.bitor(rhs),
1624             z: self.z.bitor(rhs),
1625             w: self.w.bitor(rhs),
1626         }
1627     }
1628 }
1629 
1630 impl BitXor<u16> for U16Vec4 {
1631     type Output = Self;
1632     #[inline]
bitxor(self, rhs: u16) -> Self::Output1633     fn bitxor(self, rhs: u16) -> Self::Output {
1634         Self {
1635             x: self.x.bitxor(rhs),
1636             y: self.y.bitxor(rhs),
1637             z: self.z.bitxor(rhs),
1638             w: self.w.bitxor(rhs),
1639         }
1640     }
1641 }
1642 
1643 impl Shl<i8> for U16Vec4 {
1644     type Output = Self;
1645     #[inline]
shl(self, rhs: i8) -> Self::Output1646     fn shl(self, rhs: i8) -> Self::Output {
1647         Self {
1648             x: self.x.shl(rhs),
1649             y: self.y.shl(rhs),
1650             z: self.z.shl(rhs),
1651             w: self.w.shl(rhs),
1652         }
1653     }
1654 }
1655 
1656 impl Shr<i8> for U16Vec4 {
1657     type Output = Self;
1658     #[inline]
shr(self, rhs: i8) -> Self::Output1659     fn shr(self, rhs: i8) -> Self::Output {
1660         Self {
1661             x: self.x.shr(rhs),
1662             y: self.y.shr(rhs),
1663             z: self.z.shr(rhs),
1664             w: self.w.shr(rhs),
1665         }
1666     }
1667 }
1668 
1669 impl Shl<i16> for U16Vec4 {
1670     type Output = Self;
1671     #[inline]
shl(self, rhs: i16) -> Self::Output1672     fn shl(self, rhs: i16) -> Self::Output {
1673         Self {
1674             x: self.x.shl(rhs),
1675             y: self.y.shl(rhs),
1676             z: self.z.shl(rhs),
1677             w: self.w.shl(rhs),
1678         }
1679     }
1680 }
1681 
1682 impl Shr<i16> for U16Vec4 {
1683     type Output = Self;
1684     #[inline]
shr(self, rhs: i16) -> Self::Output1685     fn shr(self, rhs: i16) -> Self::Output {
1686         Self {
1687             x: self.x.shr(rhs),
1688             y: self.y.shr(rhs),
1689             z: self.z.shr(rhs),
1690             w: self.w.shr(rhs),
1691         }
1692     }
1693 }
1694 
1695 impl Shl<i32> for U16Vec4 {
1696     type Output = Self;
1697     #[inline]
shl(self, rhs: i32) -> Self::Output1698     fn shl(self, rhs: i32) -> Self::Output {
1699         Self {
1700             x: self.x.shl(rhs),
1701             y: self.y.shl(rhs),
1702             z: self.z.shl(rhs),
1703             w: self.w.shl(rhs),
1704         }
1705     }
1706 }
1707 
1708 impl Shr<i32> for U16Vec4 {
1709     type Output = Self;
1710     #[inline]
shr(self, rhs: i32) -> Self::Output1711     fn shr(self, rhs: i32) -> Self::Output {
1712         Self {
1713             x: self.x.shr(rhs),
1714             y: self.y.shr(rhs),
1715             z: self.z.shr(rhs),
1716             w: self.w.shr(rhs),
1717         }
1718     }
1719 }
1720 
1721 impl Shl<i64> for U16Vec4 {
1722     type Output = Self;
1723     #[inline]
shl(self, rhs: i64) -> Self::Output1724     fn shl(self, rhs: i64) -> Self::Output {
1725         Self {
1726             x: self.x.shl(rhs),
1727             y: self.y.shl(rhs),
1728             z: self.z.shl(rhs),
1729             w: self.w.shl(rhs),
1730         }
1731     }
1732 }
1733 
1734 impl Shr<i64> for U16Vec4 {
1735     type Output = Self;
1736     #[inline]
shr(self, rhs: i64) -> Self::Output1737     fn shr(self, rhs: i64) -> Self::Output {
1738         Self {
1739             x: self.x.shr(rhs),
1740             y: self.y.shr(rhs),
1741             z: self.z.shr(rhs),
1742             w: self.w.shr(rhs),
1743         }
1744     }
1745 }
1746 
1747 impl Shl<u8> for U16Vec4 {
1748     type Output = Self;
1749     #[inline]
shl(self, rhs: u8) -> Self::Output1750     fn shl(self, rhs: u8) -> Self::Output {
1751         Self {
1752             x: self.x.shl(rhs),
1753             y: self.y.shl(rhs),
1754             z: self.z.shl(rhs),
1755             w: self.w.shl(rhs),
1756         }
1757     }
1758 }
1759 
1760 impl Shr<u8> for U16Vec4 {
1761     type Output = Self;
1762     #[inline]
shr(self, rhs: u8) -> Self::Output1763     fn shr(self, rhs: u8) -> Self::Output {
1764         Self {
1765             x: self.x.shr(rhs),
1766             y: self.y.shr(rhs),
1767             z: self.z.shr(rhs),
1768             w: self.w.shr(rhs),
1769         }
1770     }
1771 }
1772 
1773 impl Shl<u16> for U16Vec4 {
1774     type Output = Self;
1775     #[inline]
shl(self, rhs: u16) -> Self::Output1776     fn shl(self, rhs: u16) -> Self::Output {
1777         Self {
1778             x: self.x.shl(rhs),
1779             y: self.y.shl(rhs),
1780             z: self.z.shl(rhs),
1781             w: self.w.shl(rhs),
1782         }
1783     }
1784 }
1785 
1786 impl Shr<u16> for U16Vec4 {
1787     type Output = Self;
1788     #[inline]
shr(self, rhs: u16) -> Self::Output1789     fn shr(self, rhs: u16) -> Self::Output {
1790         Self {
1791             x: self.x.shr(rhs),
1792             y: self.y.shr(rhs),
1793             z: self.z.shr(rhs),
1794             w: self.w.shr(rhs),
1795         }
1796     }
1797 }
1798 
1799 impl Shl<u32> for U16Vec4 {
1800     type Output = Self;
1801     #[inline]
shl(self, rhs: u32) -> Self::Output1802     fn shl(self, rhs: u32) -> Self::Output {
1803         Self {
1804             x: self.x.shl(rhs),
1805             y: self.y.shl(rhs),
1806             z: self.z.shl(rhs),
1807             w: self.w.shl(rhs),
1808         }
1809     }
1810 }
1811 
1812 impl Shr<u32> for U16Vec4 {
1813     type Output = Self;
1814     #[inline]
shr(self, rhs: u32) -> Self::Output1815     fn shr(self, rhs: u32) -> Self::Output {
1816         Self {
1817             x: self.x.shr(rhs),
1818             y: self.y.shr(rhs),
1819             z: self.z.shr(rhs),
1820             w: self.w.shr(rhs),
1821         }
1822     }
1823 }
1824 
1825 impl Shl<u64> for U16Vec4 {
1826     type Output = Self;
1827     #[inline]
shl(self, rhs: u64) -> Self::Output1828     fn shl(self, rhs: u64) -> Self::Output {
1829         Self {
1830             x: self.x.shl(rhs),
1831             y: self.y.shl(rhs),
1832             z: self.z.shl(rhs),
1833             w: self.w.shl(rhs),
1834         }
1835     }
1836 }
1837 
1838 impl Shr<u64> for U16Vec4 {
1839     type Output = Self;
1840     #[inline]
shr(self, rhs: u64) -> Self::Output1841     fn shr(self, rhs: u64) -> Self::Output {
1842         Self {
1843             x: self.x.shr(rhs),
1844             y: self.y.shr(rhs),
1845             z: self.z.shr(rhs),
1846             w: self.w.shr(rhs),
1847         }
1848     }
1849 }
1850 
1851 impl Shl<crate::IVec4> for U16Vec4 {
1852     type Output = Self;
1853     #[inline]
shl(self, rhs: crate::IVec4) -> Self::Output1854     fn shl(self, rhs: crate::IVec4) -> Self::Output {
1855         Self {
1856             x: self.x.shl(rhs.x),
1857             y: self.y.shl(rhs.y),
1858             z: self.z.shl(rhs.z),
1859             w: self.w.shl(rhs.w),
1860         }
1861     }
1862 }
1863 
1864 impl Shr<crate::IVec4> for U16Vec4 {
1865     type Output = Self;
1866     #[inline]
shr(self, rhs: crate::IVec4) -> Self::Output1867     fn shr(self, rhs: crate::IVec4) -> Self::Output {
1868         Self {
1869             x: self.x.shr(rhs.x),
1870             y: self.y.shr(rhs.y),
1871             z: self.z.shr(rhs.z),
1872             w: self.w.shr(rhs.w),
1873         }
1874     }
1875 }
1876 
1877 impl Shl<crate::UVec4> for U16Vec4 {
1878     type Output = Self;
1879     #[inline]
shl(self, rhs: crate::UVec4) -> Self::Output1880     fn shl(self, rhs: crate::UVec4) -> Self::Output {
1881         Self {
1882             x: self.x.shl(rhs.x),
1883             y: self.y.shl(rhs.y),
1884             z: self.z.shl(rhs.z),
1885             w: self.w.shl(rhs.w),
1886         }
1887     }
1888 }
1889 
1890 impl Shr<crate::UVec4> for U16Vec4 {
1891     type Output = Self;
1892     #[inline]
shr(self, rhs: crate::UVec4) -> Self::Output1893     fn shr(self, rhs: crate::UVec4) -> Self::Output {
1894         Self {
1895             x: self.x.shr(rhs.x),
1896             y: self.y.shr(rhs.y),
1897             z: self.z.shr(rhs.z),
1898             w: self.w.shr(rhs.w),
1899         }
1900     }
1901 }
1902 
1903 impl Index<usize> for U16Vec4 {
1904     type Output = u16;
1905     #[inline]
index(&self, index: usize) -> &Self::Output1906     fn index(&self, index: usize) -> &Self::Output {
1907         match index {
1908             0 => &self.x,
1909             1 => &self.y,
1910             2 => &self.z,
1911             3 => &self.w,
1912             _ => panic!("index out of bounds"),
1913         }
1914     }
1915 }
1916 
1917 impl IndexMut<usize> for U16Vec4 {
1918     #[inline]
index_mut(&mut self, index: usize) -> &mut Self::Output1919     fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1920         match index {
1921             0 => &mut self.x,
1922             1 => &mut self.y,
1923             2 => &mut self.z,
1924             3 => &mut self.w,
1925             _ => panic!("index out of bounds"),
1926         }
1927     }
1928 }
1929 
1930 impl fmt::Display for U16Vec4 {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result1931     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1932         write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
1933     }
1934 }
1935 
1936 impl fmt::Debug for U16Vec4 {
fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result1937     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1938         fmt.debug_tuple(stringify!(U16Vec4))
1939             .field(&self.x)
1940             .field(&self.y)
1941             .field(&self.z)
1942             .field(&self.w)
1943             .finish()
1944     }
1945 }
1946 
1947 impl From<[u16; 4]> for U16Vec4 {
1948     #[inline]
from(a: [u16; 4]) -> Self1949     fn from(a: [u16; 4]) -> Self {
1950         Self::new(a[0], a[1], a[2], a[3])
1951     }
1952 }
1953 
1954 impl From<U16Vec4> for [u16; 4] {
1955     #[inline]
from(v: U16Vec4) -> Self1956     fn from(v: U16Vec4) -> Self {
1957         [v.x, v.y, v.z, v.w]
1958     }
1959 }
1960 
1961 impl From<(u16, u16, u16, u16)> for U16Vec4 {
1962     #[inline]
from(t: (u16, u16, u16, u16)) -> Self1963     fn from(t: (u16, u16, u16, u16)) -> Self {
1964         Self::new(t.0, t.1, t.2, t.3)
1965     }
1966 }
1967 
1968 impl From<U16Vec4> for (u16, u16, u16, u16) {
1969     #[inline]
from(v: U16Vec4) -> Self1970     fn from(v: U16Vec4) -> Self {
1971         (v.x, v.y, v.z, v.w)
1972     }
1973 }
1974 
1975 impl From<(U16Vec3, u16)> for U16Vec4 {
1976     #[inline]
from((v, w): (U16Vec3, u16)) -> Self1977     fn from((v, w): (U16Vec3, u16)) -> Self {
1978         Self::new(v.x, v.y, v.z, w)
1979     }
1980 }
1981 
1982 impl From<(u16, U16Vec3)> for U16Vec4 {
1983     #[inline]
from((x, v): (u16, U16Vec3)) -> Self1984     fn from((x, v): (u16, U16Vec3)) -> Self {
1985         Self::new(x, v.x, v.y, v.z)
1986     }
1987 }
1988 
1989 impl From<(U16Vec2, u16, u16)> for U16Vec4 {
1990     #[inline]
from((v, z, w): (U16Vec2, u16, u16)) -> Self1991     fn from((v, z, w): (U16Vec2, u16, u16)) -> Self {
1992         Self::new(v.x, v.y, z, w)
1993     }
1994 }
1995 
1996 impl From<(U16Vec2, U16Vec2)> for U16Vec4 {
1997     #[inline]
from((v, u): (U16Vec2, U16Vec2)) -> Self1998     fn from((v, u): (U16Vec2, U16Vec2)) -> Self {
1999         Self::new(v.x, v.y, u.x, u.y)
2000     }
2001 }
2002 
2003 impl From<U8Vec4> for U16Vec4 {
2004     #[inline]
from(v: U8Vec4) -> Self2005     fn from(v: U8Vec4) -> Self {
2006         Self::new(
2007             u16::from(v.x),
2008             u16::from(v.y),
2009             u16::from(v.z),
2010             u16::from(v.w),
2011         )
2012     }
2013 }
2014 
2015 impl TryFrom<I8Vec4> for U16Vec4 {
2016     type Error = core::num::TryFromIntError;
2017 
2018     #[inline]
try_from(v: I8Vec4) -> Result<Self, Self::Error>2019     fn try_from(v: I8Vec4) -> Result<Self, Self::Error> {
2020         Ok(Self::new(
2021             u16::try_from(v.x)?,
2022             u16::try_from(v.y)?,
2023             u16::try_from(v.z)?,
2024             u16::try_from(v.w)?,
2025         ))
2026     }
2027 }
2028 
2029 impl TryFrom<I16Vec4> for U16Vec4 {
2030     type Error = core::num::TryFromIntError;
2031 
2032     #[inline]
try_from(v: I16Vec4) -> Result<Self, Self::Error>2033     fn try_from(v: I16Vec4) -> Result<Self, Self::Error> {
2034         Ok(Self::new(
2035             u16::try_from(v.x)?,
2036             u16::try_from(v.y)?,
2037             u16::try_from(v.z)?,
2038             u16::try_from(v.w)?,
2039         ))
2040     }
2041 }
2042 
2043 impl TryFrom<IVec4> for U16Vec4 {
2044     type Error = core::num::TryFromIntError;
2045 
2046     #[inline]
try_from(v: IVec4) -> Result<Self, Self::Error>2047     fn try_from(v: IVec4) -> Result<Self, Self::Error> {
2048         Ok(Self::new(
2049             u16::try_from(v.x)?,
2050             u16::try_from(v.y)?,
2051             u16::try_from(v.z)?,
2052             u16::try_from(v.w)?,
2053         ))
2054     }
2055 }
2056 
2057 impl TryFrom<UVec4> for U16Vec4 {
2058     type Error = core::num::TryFromIntError;
2059 
2060     #[inline]
try_from(v: UVec4) -> Result<Self, Self::Error>2061     fn try_from(v: UVec4) -> Result<Self, Self::Error> {
2062         Ok(Self::new(
2063             u16::try_from(v.x)?,
2064             u16::try_from(v.y)?,
2065             u16::try_from(v.z)?,
2066             u16::try_from(v.w)?,
2067         ))
2068     }
2069 }
2070 
2071 impl TryFrom<I64Vec4> for U16Vec4 {
2072     type Error = core::num::TryFromIntError;
2073 
2074     #[inline]
try_from(v: I64Vec4) -> Result<Self, Self::Error>2075     fn try_from(v: I64Vec4) -> Result<Self, Self::Error> {
2076         Ok(Self::new(
2077             u16::try_from(v.x)?,
2078             u16::try_from(v.y)?,
2079             u16::try_from(v.z)?,
2080             u16::try_from(v.w)?,
2081         ))
2082     }
2083 }
2084 
2085 impl TryFrom<U64Vec4> for U16Vec4 {
2086     type Error = core::num::TryFromIntError;
2087 
2088     #[inline]
try_from(v: U64Vec4) -> Result<Self, Self::Error>2089     fn try_from(v: U64Vec4) -> Result<Self, Self::Error> {
2090         Ok(Self::new(
2091             u16::try_from(v.x)?,
2092             u16::try_from(v.y)?,
2093             u16::try_from(v.z)?,
2094             u16::try_from(v.w)?,
2095         ))
2096     }
2097 }
2098 
2099 impl From<BVec4> for U16Vec4 {
2100     #[inline]
from(v: BVec4) -> Self2101     fn from(v: BVec4) -> Self {
2102         Self::new(
2103             u16::from(v.x),
2104             u16::from(v.y),
2105             u16::from(v.z),
2106             u16::from(v.w),
2107         )
2108     }
2109 }
2110 
2111 #[cfg(not(feature = "scalar-math"))]
2112 impl From<BVec4A> for U16Vec4 {
2113     #[inline]
from(v: BVec4A) -> Self2114     fn from(v: BVec4A) -> Self {
2115         let bool_array: [bool; 4] = v.into();
2116         Self::new(
2117             u16::from(bool_array[0]),
2118             u16::from(bool_array[1]),
2119             u16::from(bool_array[2]),
2120             u16::from(bool_array[3]),
2121         )
2122     }
2123 }
2124