Skip to main content

glam/u16/
u16vec3.rs

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