glam/u16/
u16vec3.rs

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