glam/u8/
u8vec3.rs

1// Generated from vec.rs.tera template. Edit the template, not the generated file.
2
3use crate::{
4    BVec3, BVec3A, I16Vec3, I64Vec3, I8Vec3, IVec3, U16Vec3, U64Vec3, U8Vec2, U8Vec4, UVec3,
5};
6
7use core::fmt;
8use core::iter::{Product, Sum};
9use core::{f32, ops::*};
10
11/// Creates a 3-dimensional vector.
12#[inline(always)]
13#[must_use]
14pub const fn u8vec3(x: u8, y: u8, z: u8) -> U8Vec3 {
15    U8Vec3::new(x, y, z)
16}
17
18/// A 3-dimensional vector.
19#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
20#[derive(Clone, Copy, PartialEq, Eq)]
21#[cfg_attr(not(target_arch = "spirv"), repr(C))]
22#[cfg_attr(target_arch = "spirv", repr(simd))]
23pub struct U8Vec3 {
24    pub x: u8,
25    pub y: u8,
26    pub z: u8,
27}
28
29impl U8Vec3 {
30    /// All zeroes.
31    pub const ZERO: Self = Self::splat(0);
32
33    /// All ones.
34    pub const ONE: Self = Self::splat(1);
35
36    /// All `u8::MIN`.
37    pub const MIN: Self = Self::splat(u8::MIN);
38
39    /// All `u8::MAX`.
40    pub const MAX: Self = Self::splat(u8::MAX);
41
42    /// A unit vector pointing along the positive X axis.
43    pub const X: Self = Self::new(1, 0, 0);
44
45    /// A unit vector pointing along the positive Y axis.
46    pub const Y: Self = Self::new(0, 1, 0);
47
48    /// A unit vector pointing along the positive Z axis.
49    pub const Z: Self = Self::new(0, 0, 1);
50
51    /// The unit axes.
52    pub const AXES: [Self; 3] = [Self::X, Self::Y, Self::Z];
53
54    /// Creates a new vector.
55    #[inline(always)]
56    #[must_use]
57    pub const fn new(x: u8, y: u8, z: u8) -> Self {
58        Self { x, y, z }
59    }
60
61    /// Creates a vector with all elements set to `v`.
62    #[inline]
63    #[must_use]
64    pub const fn splat(v: u8) -> Self {
65        Self { x: v, y: v, z: v }
66    }
67
68    /// Returns a vector containing each element of `self` modified by a mapping function `f`.
69    #[inline]
70    #[must_use]
71    pub fn map<F>(self, f: F) -> Self
72    where
73        F: Fn(u8) -> u8,
74    {
75        Self::new(f(self.x), f(self.y), f(self.z))
76    }
77
78    /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
79    /// for each element of `self`.
80    ///
81    /// A true element in the mask uses the corresponding element from `if_true`, and false
82    /// uses the element from `if_false`.
83    #[inline]
84    #[must_use]
85    pub fn select(mask: BVec3, if_true: Self, if_false: Self) -> Self {
86        Self {
87            x: if mask.test(0) { if_true.x } else { if_false.x },
88            y: if mask.test(1) { if_true.y } else { if_false.y },
89            z: if mask.test(2) { if_true.z } else { if_false.z },
90        }
91    }
92
93    /// Creates a new vector from an array.
94    #[inline]
95    #[must_use]
96    pub const fn from_array(a: [u8; 3]) -> Self {
97        Self::new(a[0], a[1], a[2])
98    }
99
100    /// `[x, y, z]`
101    #[inline]
102    #[must_use]
103    pub const fn to_array(&self) -> [u8; 3] {
104        [self.x, self.y, self.z]
105    }
106
107    /// Creates a vector from the first 3 values in `slice`.
108    ///
109    /// # Panics
110    ///
111    /// Panics if `slice` is less than 3 elements long.
112    #[inline]
113    #[must_use]
114    pub const fn from_slice(slice: &[u8]) -> Self {
115        assert!(slice.len() >= 3);
116        Self::new(slice[0], slice[1], slice[2])
117    }
118
119    /// Writes the elements of `self` to the first 3 elements in `slice`.
120    ///
121    /// # Panics
122    ///
123    /// Panics if `slice` is less than 3 elements long.
124    #[inline]
125    pub fn write_to_slice(self, slice: &mut [u8]) {
126        slice[..3].copy_from_slice(&self.to_array());
127    }
128
129    /// Internal method for creating a 3D vector from a 4D vector, discarding `w`.
130    #[allow(dead_code)]
131    #[inline]
132    #[must_use]
133    pub(crate) fn from_vec4(v: U8Vec4) -> Self {
134        Self {
135            x: v.x,
136            y: v.y,
137            z: v.z,
138        }
139    }
140
141    /// Creates a 4D vector from `self` and the given `w` value.
142    #[inline]
143    #[must_use]
144    pub fn extend(self, w: u8) -> U8Vec4 {
145        U8Vec4::new(self.x, self.y, self.z, w)
146    }
147
148    /// Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`.
149    ///
150    /// Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()].
151    #[inline]
152    #[must_use]
153    pub fn truncate(self) -> U8Vec2 {
154        use crate::swizzles::Vec3Swizzles;
155        self.xy()
156    }
157
158    /// Creates a 3D vector from `self` with the given value of `x`.
159    #[inline]
160    #[must_use]
161    pub fn with_x(mut self, x: u8) -> Self {
162        self.x = x;
163        self
164    }
165
166    /// Creates a 3D vector from `self` with the given value of `y`.
167    #[inline]
168    #[must_use]
169    pub fn with_y(mut self, y: u8) -> Self {
170        self.y = y;
171        self
172    }
173
174    /// Creates a 3D vector from `self` with the given value of `z`.
175    #[inline]
176    #[must_use]
177    pub fn with_z(mut self, z: u8) -> Self {
178        self.z = z;
179        self
180    }
181
182    /// Computes the dot product of `self` and `rhs`.
183    #[inline]
184    #[must_use]
185    pub fn dot(self, rhs: Self) -> u8 {
186        (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
187    }
188
189    /// Returns a vector where every component is the dot product of `self` and `rhs`.
190    #[inline]
191    #[must_use]
192    pub fn dot_into_vec(self, rhs: Self) -> Self {
193        Self::splat(self.dot(rhs))
194    }
195
196    /// Computes the cross product of `self` and `rhs`.
197    #[inline]
198    #[must_use]
199    pub fn cross(self, rhs: Self) -> Self {
200        Self {
201            x: self.y * rhs.z - rhs.y * self.z,
202            y: self.z * rhs.x - rhs.z * self.x,
203            z: self.x * rhs.y - rhs.x * self.y,
204        }
205    }
206
207    /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
208    ///
209    /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
210    #[inline]
211    #[must_use]
212    pub fn min(self, rhs: Self) -> Self {
213        Self {
214            x: self.x.min(rhs.x),
215            y: self.y.min(rhs.y),
216            z: self.z.min(rhs.z),
217        }
218    }
219
220    /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
221    ///
222    /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
223    #[inline]
224    #[must_use]
225    pub fn max(self, rhs: Self) -> Self {
226        Self {
227            x: self.x.max(rhs.x),
228            y: self.y.max(rhs.y),
229            z: self.z.max(rhs.z),
230        }
231    }
232
233    /// Component-wise clamping of values, similar to [`u8::clamp`].
234    ///
235    /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
236    ///
237    /// # Panics
238    ///
239    /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
240    #[inline]
241    #[must_use]
242    pub fn clamp(self, min: Self, max: Self) -> Self {
243        glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
244        self.max(min).min(max)
245    }
246
247    /// Returns the horizontal minimum of `self`.
248    ///
249    /// In other words this computes `min(x, y, ..)`.
250    #[inline]
251    #[must_use]
252    pub fn min_element(self) -> u8 {
253        self.x.min(self.y.min(self.z))
254    }
255
256    /// Returns the horizontal maximum of `self`.
257    ///
258    /// In other words this computes `max(x, y, ..)`.
259    #[inline]
260    #[must_use]
261    pub fn max_element(self) -> u8 {
262        self.x.max(self.y.max(self.z))
263    }
264
265    /// Returns the sum of all elements of `self`.
266    ///
267    /// In other words, this computes `self.x + self.y + ..`.
268    #[inline]
269    #[must_use]
270    pub fn element_sum(self) -> u8 {
271        self.x + self.y + self.z
272    }
273
274    /// Returns the product of all elements of `self`.
275    ///
276    /// In other words, this computes `self.x * self.y * ..`.
277    #[inline]
278    #[must_use]
279    pub fn element_product(self) -> u8 {
280        self.x * self.y * self.z
281    }
282
283    /// Returns a vector mask containing the result of a `==` comparison for each element of
284    /// `self` and `rhs`.
285    ///
286    /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
287    /// elements.
288    #[inline]
289    #[must_use]
290    pub fn cmpeq(self, rhs: Self) -> BVec3 {
291        BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z))
292    }
293
294    /// Returns a vector mask containing the result of a `!=` comparison for each element of
295    /// `self` and `rhs`.
296    ///
297    /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
298    /// elements.
299    #[inline]
300    #[must_use]
301    pub fn cmpne(self, rhs: Self) -> BVec3 {
302        BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z))
303    }
304
305    /// Returns a vector mask containing the result of a `>=` comparison for each element of
306    /// `self` and `rhs`.
307    ///
308    /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
309    /// elements.
310    #[inline]
311    #[must_use]
312    pub fn cmpge(self, rhs: Self) -> BVec3 {
313        BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z))
314    }
315
316    /// Returns a vector mask containing the result of a `>` comparison for each element of
317    /// `self` and `rhs`.
318    ///
319    /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
320    /// elements.
321    #[inline]
322    #[must_use]
323    pub fn cmpgt(self, rhs: Self) -> BVec3 {
324        BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.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 cmple(self, rhs: Self) -> BVec3 {
335        BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&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 cmplt(self, rhs: Self) -> BVec3 {
346        BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z))
347    }
348
349    /// Computes the squared length of `self`.
350    #[doc(alias = "magnitude2")]
351    #[inline]
352    #[must_use]
353    pub fn length_squared(self) -> u8 {
354        self.dot(self)
355    }
356
357    /// Casts all elements of `self` to `f32`.
358    #[inline]
359    #[must_use]
360    pub fn as_vec3(&self) -> crate::Vec3 {
361        crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32)
362    }
363
364    /// Casts all elements of `self` to `f32`.
365    #[inline]
366    #[must_use]
367    pub fn as_vec3a(&self) -> crate::Vec3A {
368        crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32)
369    }
370
371    /// Casts all elements of `self` to `f64`.
372    #[inline]
373    #[must_use]
374    pub fn as_dvec3(&self) -> crate::DVec3 {
375        crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64)
376    }
377
378    /// Casts all elements of `self` to `i8`.
379    #[inline]
380    #[must_use]
381    pub fn as_i8vec3(&self) -> crate::I8Vec3 {
382        crate::I8Vec3::new(self.x as i8, self.y as i8, self.z as i8)
383    }
384
385    /// Casts all elements of `self` to `i16`.
386    #[inline]
387    #[must_use]
388    pub fn as_i16vec3(&self) -> crate::I16Vec3 {
389        crate::I16Vec3::new(self.x as i16, self.y as i16, self.z as i16)
390    }
391
392    /// Casts all elements of `self` to `u16`.
393    #[inline]
394    #[must_use]
395    pub fn as_u16vec3(&self) -> crate::U16Vec3 {
396        crate::U16Vec3::new(self.x as u16, self.y as u16, self.z as u16)
397    }
398
399    /// Casts all elements of `self` to `i32`.
400    #[inline]
401    #[must_use]
402    pub fn as_ivec3(&self) -> crate::IVec3 {
403        crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32)
404    }
405
406    /// Casts all elements of `self` to `u32`.
407    #[inline]
408    #[must_use]
409    pub fn as_uvec3(&self) -> crate::UVec3 {
410        crate::UVec3::new(self.x as u32, self.y as u32, self.z as u32)
411    }
412
413    /// Casts all elements of `self` to `i64`.
414    #[inline]
415    #[must_use]
416    pub fn as_i64vec3(&self) -> crate::I64Vec3 {
417        crate::I64Vec3::new(self.x as i64, self.y as i64, self.z as i64)
418    }
419
420    /// Casts all elements of `self` to `u64`.
421    #[inline]
422    #[must_use]
423    pub fn as_u64vec3(&self) -> crate::U64Vec3 {
424        crate::U64Vec3::new(self.x as u64, self.y as u64, self.z as u64)
425    }
426
427    /// Returns a vector containing the wrapping addition of `self` and `rhs`.
428    ///
429    /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
430    #[inline]
431    #[must_use]
432    pub const fn wrapping_add(self, rhs: Self) -> Self {
433        Self {
434            x: self.x.wrapping_add(rhs.x),
435            y: self.y.wrapping_add(rhs.y),
436            z: self.z.wrapping_add(rhs.z),
437        }
438    }
439
440    /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
441    ///
442    /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
443    #[inline]
444    #[must_use]
445    pub const fn wrapping_sub(self, rhs: Self) -> Self {
446        Self {
447            x: self.x.wrapping_sub(rhs.x),
448            y: self.y.wrapping_sub(rhs.y),
449            z: self.z.wrapping_sub(rhs.z),
450        }
451    }
452
453    /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
454    ///
455    /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
456    #[inline]
457    #[must_use]
458    pub const fn wrapping_mul(self, rhs: Self) -> Self {
459        Self {
460            x: self.x.wrapping_mul(rhs.x),
461            y: self.y.wrapping_mul(rhs.y),
462            z: self.z.wrapping_mul(rhs.z),
463        }
464    }
465
466    /// Returns a vector containing the wrapping division of `self` and `rhs`.
467    ///
468    /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
469    #[inline]
470    #[must_use]
471    pub const fn wrapping_div(self, rhs: Self) -> Self {
472        Self {
473            x: self.x.wrapping_div(rhs.x),
474            y: self.y.wrapping_div(rhs.y),
475            z: self.z.wrapping_div(rhs.z),
476        }
477    }
478
479    /// Returns a vector containing the saturating addition of `self` and `rhs`.
480    ///
481    /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
482    #[inline]
483    #[must_use]
484    pub const fn saturating_add(self, rhs: Self) -> Self {
485        Self {
486            x: self.x.saturating_add(rhs.x),
487            y: self.y.saturating_add(rhs.y),
488            z: self.z.saturating_add(rhs.z),
489        }
490    }
491
492    /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
493    ///
494    /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
495    #[inline]
496    #[must_use]
497    pub const fn saturating_sub(self, rhs: Self) -> Self {
498        Self {
499            x: self.x.saturating_sub(rhs.x),
500            y: self.y.saturating_sub(rhs.y),
501            z: self.z.saturating_sub(rhs.z),
502        }
503    }
504
505    /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
506    ///
507    /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
508    #[inline]
509    #[must_use]
510    pub const fn saturating_mul(self, rhs: Self) -> Self {
511        Self {
512            x: self.x.saturating_mul(rhs.x),
513            y: self.y.saturating_mul(rhs.y),
514            z: self.z.saturating_mul(rhs.z),
515        }
516    }
517
518    /// Returns a vector containing the saturating division of `self` and `rhs`.
519    ///
520    /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
521    #[inline]
522    #[must_use]
523    pub const fn saturating_div(self, rhs: Self) -> Self {
524        Self {
525            x: self.x.saturating_div(rhs.x),
526            y: self.y.saturating_div(rhs.y),
527            z: self.z.saturating_div(rhs.z),
528        }
529    }
530
531    /// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`.
532    ///
533    /// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`.
534    #[inline]
535    #[must_use]
536    pub const fn wrapping_add_signed(self, rhs: I8Vec3) -> Self {
537        Self {
538            x: self.x.wrapping_add_signed(rhs.x),
539            y: self.y.wrapping_add_signed(rhs.y),
540            z: self.z.wrapping_add_signed(rhs.z),
541        }
542    }
543
544    /// Returns a vector containing the saturating addition of `self` and signed vector `rhs`.
545    ///
546    /// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`.
547    #[inline]
548    #[must_use]
549    pub const fn saturating_add_signed(self, rhs: I8Vec3) -> Self {
550        Self {
551            x: self.x.saturating_add_signed(rhs.x),
552            y: self.y.saturating_add_signed(rhs.y),
553            z: self.z.saturating_add_signed(rhs.z),
554        }
555    }
556}
557
558impl Default for U8Vec3 {
559    #[inline(always)]
560    fn default() -> Self {
561        Self::ZERO
562    }
563}
564
565impl Div<U8Vec3> for U8Vec3 {
566    type Output = Self;
567    #[inline]
568    fn div(self, rhs: Self) -> Self {
569        Self {
570            x: self.x.div(rhs.x),
571            y: self.y.div(rhs.y),
572            z: self.z.div(rhs.z),
573        }
574    }
575}
576
577impl Div<&U8Vec3> for U8Vec3 {
578    type Output = U8Vec3;
579    #[inline]
580    fn div(self, rhs: &U8Vec3) -> U8Vec3 {
581        self.div(*rhs)
582    }
583}
584
585impl Div<&U8Vec3> for &U8Vec3 {
586    type Output = U8Vec3;
587    #[inline]
588    fn div(self, rhs: &U8Vec3) -> U8Vec3 {
589        (*self).div(*rhs)
590    }
591}
592
593impl Div<U8Vec3> for &U8Vec3 {
594    type Output = U8Vec3;
595    #[inline]
596    fn div(self, rhs: U8Vec3) -> U8Vec3 {
597        (*self).div(rhs)
598    }
599}
600
601impl DivAssign<U8Vec3> for U8Vec3 {
602    #[inline]
603    fn div_assign(&mut self, rhs: Self) {
604        self.x.div_assign(rhs.x);
605        self.y.div_assign(rhs.y);
606        self.z.div_assign(rhs.z);
607    }
608}
609
610impl DivAssign<&Self> for U8Vec3 {
611    #[inline]
612    fn div_assign(&mut self, rhs: &Self) {
613        self.div_assign(*rhs)
614    }
615}
616
617impl Div<u8> for U8Vec3 {
618    type Output = Self;
619    #[inline]
620    fn div(self, rhs: u8) -> Self {
621        Self {
622            x: self.x.div(rhs),
623            y: self.y.div(rhs),
624            z: self.z.div(rhs),
625        }
626    }
627}
628
629impl Div<&u8> for U8Vec3 {
630    type Output = U8Vec3;
631    #[inline]
632    fn div(self, rhs: &u8) -> U8Vec3 {
633        self.div(*rhs)
634    }
635}
636
637impl Div<&u8> for &U8Vec3 {
638    type Output = U8Vec3;
639    #[inline]
640    fn div(self, rhs: &u8) -> U8Vec3 {
641        (*self).div(*rhs)
642    }
643}
644
645impl Div<u8> for &U8Vec3 {
646    type Output = U8Vec3;
647    #[inline]
648    fn div(self, rhs: u8) -> U8Vec3 {
649        (*self).div(rhs)
650    }
651}
652
653impl DivAssign<u8> for U8Vec3 {
654    #[inline]
655    fn div_assign(&mut self, rhs: u8) {
656        self.x.div_assign(rhs);
657        self.y.div_assign(rhs);
658        self.z.div_assign(rhs);
659    }
660}
661
662impl DivAssign<&u8> for U8Vec3 {
663    #[inline]
664    fn div_assign(&mut self, rhs: &u8) {
665        self.div_assign(*rhs)
666    }
667}
668
669impl Div<U8Vec3> for u8 {
670    type Output = U8Vec3;
671    #[inline]
672    fn div(self, rhs: U8Vec3) -> U8Vec3 {
673        U8Vec3 {
674            x: self.div(rhs.x),
675            y: self.div(rhs.y),
676            z: self.div(rhs.z),
677        }
678    }
679}
680
681impl Div<&U8Vec3> for u8 {
682    type Output = U8Vec3;
683    #[inline]
684    fn div(self, rhs: &U8Vec3) -> U8Vec3 {
685        self.div(*rhs)
686    }
687}
688
689impl Div<&U8Vec3> for &u8 {
690    type Output = U8Vec3;
691    #[inline]
692    fn div(self, rhs: &U8Vec3) -> U8Vec3 {
693        (*self).div(*rhs)
694    }
695}
696
697impl Div<U8Vec3> for &u8 {
698    type Output = U8Vec3;
699    #[inline]
700    fn div(self, rhs: U8Vec3) -> U8Vec3 {
701        (*self).div(rhs)
702    }
703}
704
705impl Mul<U8Vec3> for U8Vec3 {
706    type Output = Self;
707    #[inline]
708    fn mul(self, rhs: Self) -> Self {
709        Self {
710            x: self.x.mul(rhs.x),
711            y: self.y.mul(rhs.y),
712            z: self.z.mul(rhs.z),
713        }
714    }
715}
716
717impl Mul<&U8Vec3> for U8Vec3 {
718    type Output = U8Vec3;
719    #[inline]
720    fn mul(self, rhs: &U8Vec3) -> U8Vec3 {
721        self.mul(*rhs)
722    }
723}
724
725impl Mul<&U8Vec3> for &U8Vec3 {
726    type Output = U8Vec3;
727    #[inline]
728    fn mul(self, rhs: &U8Vec3) -> U8Vec3 {
729        (*self).mul(*rhs)
730    }
731}
732
733impl Mul<U8Vec3> for &U8Vec3 {
734    type Output = U8Vec3;
735    #[inline]
736    fn mul(self, rhs: U8Vec3) -> U8Vec3 {
737        (*self).mul(rhs)
738    }
739}
740
741impl MulAssign<U8Vec3> for U8Vec3 {
742    #[inline]
743    fn mul_assign(&mut self, rhs: Self) {
744        self.x.mul_assign(rhs.x);
745        self.y.mul_assign(rhs.y);
746        self.z.mul_assign(rhs.z);
747    }
748}
749
750impl MulAssign<&Self> for U8Vec3 {
751    #[inline]
752    fn mul_assign(&mut self, rhs: &Self) {
753        self.mul_assign(*rhs)
754    }
755}
756
757impl Mul<u8> for U8Vec3 {
758    type Output = Self;
759    #[inline]
760    fn mul(self, rhs: u8) -> Self {
761        Self {
762            x: self.x.mul(rhs),
763            y: self.y.mul(rhs),
764            z: self.z.mul(rhs),
765        }
766    }
767}
768
769impl Mul<&u8> for U8Vec3 {
770    type Output = U8Vec3;
771    #[inline]
772    fn mul(self, rhs: &u8) -> U8Vec3 {
773        self.mul(*rhs)
774    }
775}
776
777impl Mul<&u8> for &U8Vec3 {
778    type Output = U8Vec3;
779    #[inline]
780    fn mul(self, rhs: &u8) -> U8Vec3 {
781        (*self).mul(*rhs)
782    }
783}
784
785impl Mul<u8> for &U8Vec3 {
786    type Output = U8Vec3;
787    #[inline]
788    fn mul(self, rhs: u8) -> U8Vec3 {
789        (*self).mul(rhs)
790    }
791}
792
793impl MulAssign<u8> for U8Vec3 {
794    #[inline]
795    fn mul_assign(&mut self, rhs: u8) {
796        self.x.mul_assign(rhs);
797        self.y.mul_assign(rhs);
798        self.z.mul_assign(rhs);
799    }
800}
801
802impl MulAssign<&u8> for U8Vec3 {
803    #[inline]
804    fn mul_assign(&mut self, rhs: &u8) {
805        self.mul_assign(*rhs)
806    }
807}
808
809impl Mul<U8Vec3> for u8 {
810    type Output = U8Vec3;
811    #[inline]
812    fn mul(self, rhs: U8Vec3) -> U8Vec3 {
813        U8Vec3 {
814            x: self.mul(rhs.x),
815            y: self.mul(rhs.y),
816            z: self.mul(rhs.z),
817        }
818    }
819}
820
821impl Mul<&U8Vec3> for u8 {
822    type Output = U8Vec3;
823    #[inline]
824    fn mul(self, rhs: &U8Vec3) -> U8Vec3 {
825        self.mul(*rhs)
826    }
827}
828
829impl Mul<&U8Vec3> for &u8 {
830    type Output = U8Vec3;
831    #[inline]
832    fn mul(self, rhs: &U8Vec3) -> U8Vec3 {
833        (*self).mul(*rhs)
834    }
835}
836
837impl Mul<U8Vec3> for &u8 {
838    type Output = U8Vec3;
839    #[inline]
840    fn mul(self, rhs: U8Vec3) -> U8Vec3 {
841        (*self).mul(rhs)
842    }
843}
844
845impl Add<U8Vec3> for U8Vec3 {
846    type Output = Self;
847    #[inline]
848    fn add(self, rhs: Self) -> Self {
849        Self {
850            x: self.x.add(rhs.x),
851            y: self.y.add(rhs.y),
852            z: self.z.add(rhs.z),
853        }
854    }
855}
856
857impl Add<&U8Vec3> for U8Vec3 {
858    type Output = U8Vec3;
859    #[inline]
860    fn add(self, rhs: &U8Vec3) -> U8Vec3 {
861        self.add(*rhs)
862    }
863}
864
865impl Add<&U8Vec3> for &U8Vec3 {
866    type Output = U8Vec3;
867    #[inline]
868    fn add(self, rhs: &U8Vec3) -> U8Vec3 {
869        (*self).add(*rhs)
870    }
871}
872
873impl Add<U8Vec3> for &U8Vec3 {
874    type Output = U8Vec3;
875    #[inline]
876    fn add(self, rhs: U8Vec3) -> U8Vec3 {
877        (*self).add(rhs)
878    }
879}
880
881impl AddAssign<U8Vec3> for U8Vec3 {
882    #[inline]
883    fn add_assign(&mut self, rhs: Self) {
884        self.x.add_assign(rhs.x);
885        self.y.add_assign(rhs.y);
886        self.z.add_assign(rhs.z);
887    }
888}
889
890impl AddAssign<&Self> for U8Vec3 {
891    #[inline]
892    fn add_assign(&mut self, rhs: &Self) {
893        self.add_assign(*rhs)
894    }
895}
896
897impl Add<u8> for U8Vec3 {
898    type Output = Self;
899    #[inline]
900    fn add(self, rhs: u8) -> Self {
901        Self {
902            x: self.x.add(rhs),
903            y: self.y.add(rhs),
904            z: self.z.add(rhs),
905        }
906    }
907}
908
909impl Add<&u8> for U8Vec3 {
910    type Output = U8Vec3;
911    #[inline]
912    fn add(self, rhs: &u8) -> U8Vec3 {
913        self.add(*rhs)
914    }
915}
916
917impl Add<&u8> for &U8Vec3 {
918    type Output = U8Vec3;
919    #[inline]
920    fn add(self, rhs: &u8) -> U8Vec3 {
921        (*self).add(*rhs)
922    }
923}
924
925impl Add<u8> for &U8Vec3 {
926    type Output = U8Vec3;
927    #[inline]
928    fn add(self, rhs: u8) -> U8Vec3 {
929        (*self).add(rhs)
930    }
931}
932
933impl AddAssign<u8> for U8Vec3 {
934    #[inline]
935    fn add_assign(&mut self, rhs: u8) {
936        self.x.add_assign(rhs);
937        self.y.add_assign(rhs);
938        self.z.add_assign(rhs);
939    }
940}
941
942impl AddAssign<&u8> for U8Vec3 {
943    #[inline]
944    fn add_assign(&mut self, rhs: &u8) {
945        self.add_assign(*rhs)
946    }
947}
948
949impl Add<U8Vec3> for u8 {
950    type Output = U8Vec3;
951    #[inline]
952    fn add(self, rhs: U8Vec3) -> U8Vec3 {
953        U8Vec3 {
954            x: self.add(rhs.x),
955            y: self.add(rhs.y),
956            z: self.add(rhs.z),
957        }
958    }
959}
960
961impl Add<&U8Vec3> for u8 {
962    type Output = U8Vec3;
963    #[inline]
964    fn add(self, rhs: &U8Vec3) -> U8Vec3 {
965        self.add(*rhs)
966    }
967}
968
969impl Add<&U8Vec3> for &u8 {
970    type Output = U8Vec3;
971    #[inline]
972    fn add(self, rhs: &U8Vec3) -> U8Vec3 {
973        (*self).add(*rhs)
974    }
975}
976
977impl Add<U8Vec3> for &u8 {
978    type Output = U8Vec3;
979    #[inline]
980    fn add(self, rhs: U8Vec3) -> U8Vec3 {
981        (*self).add(rhs)
982    }
983}
984
985impl Sub<U8Vec3> for U8Vec3 {
986    type Output = Self;
987    #[inline]
988    fn sub(self, rhs: Self) -> Self {
989        Self {
990            x: self.x.sub(rhs.x),
991            y: self.y.sub(rhs.y),
992            z: self.z.sub(rhs.z),
993        }
994    }
995}
996
997impl Sub<&U8Vec3> for U8Vec3 {
998    type Output = U8Vec3;
999    #[inline]
1000    fn sub(self, rhs: &U8Vec3) -> U8Vec3 {
1001        self.sub(*rhs)
1002    }
1003}
1004
1005impl Sub<&U8Vec3> for &U8Vec3 {
1006    type Output = U8Vec3;
1007    #[inline]
1008    fn sub(self, rhs: &U8Vec3) -> U8Vec3 {
1009        (*self).sub(*rhs)
1010    }
1011}
1012
1013impl Sub<U8Vec3> for &U8Vec3 {
1014    type Output = U8Vec3;
1015    #[inline]
1016    fn sub(self, rhs: U8Vec3) -> U8Vec3 {
1017        (*self).sub(rhs)
1018    }
1019}
1020
1021impl SubAssign<U8Vec3> for U8Vec3 {
1022    #[inline]
1023    fn sub_assign(&mut self, rhs: U8Vec3) {
1024        self.x.sub_assign(rhs.x);
1025        self.y.sub_assign(rhs.y);
1026        self.z.sub_assign(rhs.z);
1027    }
1028}
1029
1030impl SubAssign<&Self> for U8Vec3 {
1031    #[inline]
1032    fn sub_assign(&mut self, rhs: &Self) {
1033        self.sub_assign(*rhs)
1034    }
1035}
1036
1037impl Sub<u8> for U8Vec3 {
1038    type Output = Self;
1039    #[inline]
1040    fn sub(self, rhs: u8) -> Self {
1041        Self {
1042            x: self.x.sub(rhs),
1043            y: self.y.sub(rhs),
1044            z: self.z.sub(rhs),
1045        }
1046    }
1047}
1048
1049impl Sub<&u8> for U8Vec3 {
1050    type Output = U8Vec3;
1051    #[inline]
1052    fn sub(self, rhs: &u8) -> U8Vec3 {
1053        self.sub(*rhs)
1054    }
1055}
1056
1057impl Sub<&u8> for &U8Vec3 {
1058    type Output = U8Vec3;
1059    #[inline]
1060    fn sub(self, rhs: &u8) -> U8Vec3 {
1061        (*self).sub(*rhs)
1062    }
1063}
1064
1065impl Sub<u8> for &U8Vec3 {
1066    type Output = U8Vec3;
1067    #[inline]
1068    fn sub(self, rhs: u8) -> U8Vec3 {
1069        (*self).sub(rhs)
1070    }
1071}
1072
1073impl SubAssign<u8> for U8Vec3 {
1074    #[inline]
1075    fn sub_assign(&mut self, rhs: u8) {
1076        self.x.sub_assign(rhs);
1077        self.y.sub_assign(rhs);
1078        self.z.sub_assign(rhs);
1079    }
1080}
1081
1082impl SubAssign<&u8> for U8Vec3 {
1083    #[inline]
1084    fn sub_assign(&mut self, rhs: &u8) {
1085        self.sub_assign(*rhs)
1086    }
1087}
1088
1089impl Sub<U8Vec3> for u8 {
1090    type Output = U8Vec3;
1091    #[inline]
1092    fn sub(self, rhs: U8Vec3) -> U8Vec3 {
1093        U8Vec3 {
1094            x: self.sub(rhs.x),
1095            y: self.sub(rhs.y),
1096            z: self.sub(rhs.z),
1097        }
1098    }
1099}
1100
1101impl Sub<&U8Vec3> for u8 {
1102    type Output = U8Vec3;
1103    #[inline]
1104    fn sub(self, rhs: &U8Vec3) -> U8Vec3 {
1105        self.sub(*rhs)
1106    }
1107}
1108
1109impl Sub<&U8Vec3> for &u8 {
1110    type Output = U8Vec3;
1111    #[inline]
1112    fn sub(self, rhs: &U8Vec3) -> U8Vec3 {
1113        (*self).sub(*rhs)
1114    }
1115}
1116
1117impl Sub<U8Vec3> for &u8 {
1118    type Output = U8Vec3;
1119    #[inline]
1120    fn sub(self, rhs: U8Vec3) -> U8Vec3 {
1121        (*self).sub(rhs)
1122    }
1123}
1124
1125impl Rem<U8Vec3> for U8Vec3 {
1126    type Output = Self;
1127    #[inline]
1128    fn rem(self, rhs: Self) -> Self {
1129        Self {
1130            x: self.x.rem(rhs.x),
1131            y: self.y.rem(rhs.y),
1132            z: self.z.rem(rhs.z),
1133        }
1134    }
1135}
1136
1137impl Rem<&U8Vec3> for U8Vec3 {
1138    type Output = U8Vec3;
1139    #[inline]
1140    fn rem(self, rhs: &U8Vec3) -> U8Vec3 {
1141        self.rem(*rhs)
1142    }
1143}
1144
1145impl Rem<&U8Vec3> for &U8Vec3 {
1146    type Output = U8Vec3;
1147    #[inline]
1148    fn rem(self, rhs: &U8Vec3) -> U8Vec3 {
1149        (*self).rem(*rhs)
1150    }
1151}
1152
1153impl Rem<U8Vec3> for &U8Vec3 {
1154    type Output = U8Vec3;
1155    #[inline]
1156    fn rem(self, rhs: U8Vec3) -> U8Vec3 {
1157        (*self).rem(rhs)
1158    }
1159}
1160
1161impl RemAssign<U8Vec3> for U8Vec3 {
1162    #[inline]
1163    fn rem_assign(&mut self, rhs: Self) {
1164        self.x.rem_assign(rhs.x);
1165        self.y.rem_assign(rhs.y);
1166        self.z.rem_assign(rhs.z);
1167    }
1168}
1169
1170impl RemAssign<&Self> for U8Vec3 {
1171    #[inline]
1172    fn rem_assign(&mut self, rhs: &Self) {
1173        self.rem_assign(*rhs)
1174    }
1175}
1176
1177impl Rem<u8> for U8Vec3 {
1178    type Output = Self;
1179    #[inline]
1180    fn rem(self, rhs: u8) -> Self {
1181        Self {
1182            x: self.x.rem(rhs),
1183            y: self.y.rem(rhs),
1184            z: self.z.rem(rhs),
1185        }
1186    }
1187}
1188
1189impl Rem<&u8> for U8Vec3 {
1190    type Output = U8Vec3;
1191    #[inline]
1192    fn rem(self, rhs: &u8) -> U8Vec3 {
1193        self.rem(*rhs)
1194    }
1195}
1196
1197impl Rem<&u8> for &U8Vec3 {
1198    type Output = U8Vec3;
1199    #[inline]
1200    fn rem(self, rhs: &u8) -> U8Vec3 {
1201        (*self).rem(*rhs)
1202    }
1203}
1204
1205impl Rem<u8> for &U8Vec3 {
1206    type Output = U8Vec3;
1207    #[inline]
1208    fn rem(self, rhs: u8) -> U8Vec3 {
1209        (*self).rem(rhs)
1210    }
1211}
1212
1213impl RemAssign<u8> for U8Vec3 {
1214    #[inline]
1215    fn rem_assign(&mut self, rhs: u8) {
1216        self.x.rem_assign(rhs);
1217        self.y.rem_assign(rhs);
1218        self.z.rem_assign(rhs);
1219    }
1220}
1221
1222impl RemAssign<&u8> for U8Vec3 {
1223    #[inline]
1224    fn rem_assign(&mut self, rhs: &u8) {
1225        self.rem_assign(*rhs)
1226    }
1227}
1228
1229impl Rem<U8Vec3> for u8 {
1230    type Output = U8Vec3;
1231    #[inline]
1232    fn rem(self, rhs: U8Vec3) -> U8Vec3 {
1233        U8Vec3 {
1234            x: self.rem(rhs.x),
1235            y: self.rem(rhs.y),
1236            z: self.rem(rhs.z),
1237        }
1238    }
1239}
1240
1241impl Rem<&U8Vec3> for u8 {
1242    type Output = U8Vec3;
1243    #[inline]
1244    fn rem(self, rhs: &U8Vec3) -> U8Vec3 {
1245        self.rem(*rhs)
1246    }
1247}
1248
1249impl Rem<&U8Vec3> for &u8 {
1250    type Output = U8Vec3;
1251    #[inline]
1252    fn rem(self, rhs: &U8Vec3) -> U8Vec3 {
1253        (*self).rem(*rhs)
1254    }
1255}
1256
1257impl Rem<U8Vec3> for &u8 {
1258    type Output = U8Vec3;
1259    #[inline]
1260    fn rem(self, rhs: U8Vec3) -> U8Vec3 {
1261        (*self).rem(rhs)
1262    }
1263}
1264
1265#[cfg(not(target_arch = "spirv"))]
1266impl AsRef<[u8; 3]> for U8Vec3 {
1267    #[inline]
1268    fn as_ref(&self) -> &[u8; 3] {
1269        unsafe { &*(self as *const U8Vec3 as *const [u8; 3]) }
1270    }
1271}
1272
1273#[cfg(not(target_arch = "spirv"))]
1274impl AsMut<[u8; 3]> for U8Vec3 {
1275    #[inline]
1276    fn as_mut(&mut self) -> &mut [u8; 3] {
1277        unsafe { &mut *(self as *mut U8Vec3 as *mut [u8; 3]) }
1278    }
1279}
1280
1281impl Sum for U8Vec3 {
1282    #[inline]
1283    fn sum<I>(iter: I) -> Self
1284    where
1285        I: Iterator<Item = Self>,
1286    {
1287        iter.fold(Self::ZERO, Self::add)
1288    }
1289}
1290
1291impl<'a> Sum<&'a Self> for U8Vec3 {
1292    #[inline]
1293    fn sum<I>(iter: I) -> Self
1294    where
1295        I: Iterator<Item = &'a Self>,
1296    {
1297        iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1298    }
1299}
1300
1301impl Product for U8Vec3 {
1302    #[inline]
1303    fn product<I>(iter: I) -> Self
1304    where
1305        I: Iterator<Item = Self>,
1306    {
1307        iter.fold(Self::ONE, Self::mul)
1308    }
1309}
1310
1311impl<'a> Product<&'a Self> for U8Vec3 {
1312    #[inline]
1313    fn product<I>(iter: I) -> Self
1314    where
1315        I: Iterator<Item = &'a Self>,
1316    {
1317        iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1318    }
1319}
1320
1321impl Not for U8Vec3 {
1322    type Output = Self;
1323    #[inline]
1324    fn not(self) -> Self::Output {
1325        Self {
1326            x: self.x.not(),
1327            y: self.y.not(),
1328            z: self.z.not(),
1329        }
1330    }
1331}
1332
1333impl BitAnd for U8Vec3 {
1334    type Output = Self;
1335    #[inline]
1336    fn bitand(self, rhs: Self) -> Self::Output {
1337        Self {
1338            x: self.x.bitand(rhs.x),
1339            y: self.y.bitand(rhs.y),
1340            z: self.z.bitand(rhs.z),
1341        }
1342    }
1343}
1344
1345impl BitOr for U8Vec3 {
1346    type Output = Self;
1347    #[inline]
1348    fn bitor(self, rhs: Self) -> Self::Output {
1349        Self {
1350            x: self.x.bitor(rhs.x),
1351            y: self.y.bitor(rhs.y),
1352            z: self.z.bitor(rhs.z),
1353        }
1354    }
1355}
1356
1357impl BitXor for U8Vec3 {
1358    type Output = Self;
1359    #[inline]
1360    fn bitxor(self, rhs: Self) -> Self::Output {
1361        Self {
1362            x: self.x.bitxor(rhs.x),
1363            y: self.y.bitxor(rhs.y),
1364            z: self.z.bitxor(rhs.z),
1365        }
1366    }
1367}
1368
1369impl BitAnd<u8> for U8Vec3 {
1370    type Output = Self;
1371    #[inline]
1372    fn bitand(self, rhs: u8) -> Self::Output {
1373        Self {
1374            x: self.x.bitand(rhs),
1375            y: self.y.bitand(rhs),
1376            z: self.z.bitand(rhs),
1377        }
1378    }
1379}
1380
1381impl BitOr<u8> for U8Vec3 {
1382    type Output = Self;
1383    #[inline]
1384    fn bitor(self, rhs: u8) -> Self::Output {
1385        Self {
1386            x: self.x.bitor(rhs),
1387            y: self.y.bitor(rhs),
1388            z: self.z.bitor(rhs),
1389        }
1390    }
1391}
1392
1393impl BitXor<u8> for U8Vec3 {
1394    type Output = Self;
1395    #[inline]
1396    fn bitxor(self, rhs: u8) -> Self::Output {
1397        Self {
1398            x: self.x.bitxor(rhs),
1399            y: self.y.bitxor(rhs),
1400            z: self.z.bitxor(rhs),
1401        }
1402    }
1403}
1404
1405impl Shl<i8> for U8Vec3 {
1406    type Output = Self;
1407    #[inline]
1408    fn shl(self, rhs: i8) -> Self::Output {
1409        Self {
1410            x: self.x.shl(rhs),
1411            y: self.y.shl(rhs),
1412            z: self.z.shl(rhs),
1413        }
1414    }
1415}
1416
1417impl Shr<i8> for U8Vec3 {
1418    type Output = Self;
1419    #[inline]
1420    fn shr(self, rhs: i8) -> Self::Output {
1421        Self {
1422            x: self.x.shr(rhs),
1423            y: self.y.shr(rhs),
1424            z: self.z.shr(rhs),
1425        }
1426    }
1427}
1428
1429impl Shl<i16> for U8Vec3 {
1430    type Output = Self;
1431    #[inline]
1432    fn shl(self, rhs: i16) -> Self::Output {
1433        Self {
1434            x: self.x.shl(rhs),
1435            y: self.y.shl(rhs),
1436            z: self.z.shl(rhs),
1437        }
1438    }
1439}
1440
1441impl Shr<i16> for U8Vec3 {
1442    type Output = Self;
1443    #[inline]
1444    fn shr(self, rhs: i16) -> Self::Output {
1445        Self {
1446            x: self.x.shr(rhs),
1447            y: self.y.shr(rhs),
1448            z: self.z.shr(rhs),
1449        }
1450    }
1451}
1452
1453impl Shl<i32> for U8Vec3 {
1454    type Output = Self;
1455    #[inline]
1456    fn shl(self, rhs: i32) -> Self::Output {
1457        Self {
1458            x: self.x.shl(rhs),
1459            y: self.y.shl(rhs),
1460            z: self.z.shl(rhs),
1461        }
1462    }
1463}
1464
1465impl Shr<i32> for U8Vec3 {
1466    type Output = Self;
1467    #[inline]
1468    fn shr(self, rhs: i32) -> Self::Output {
1469        Self {
1470            x: self.x.shr(rhs),
1471            y: self.y.shr(rhs),
1472            z: self.z.shr(rhs),
1473        }
1474    }
1475}
1476
1477impl Shl<i64> for U8Vec3 {
1478    type Output = Self;
1479    #[inline]
1480    fn shl(self, rhs: i64) -> Self::Output {
1481        Self {
1482            x: self.x.shl(rhs),
1483            y: self.y.shl(rhs),
1484            z: self.z.shl(rhs),
1485        }
1486    }
1487}
1488
1489impl Shr<i64> for U8Vec3 {
1490    type Output = Self;
1491    #[inline]
1492    fn shr(self, rhs: i64) -> Self::Output {
1493        Self {
1494            x: self.x.shr(rhs),
1495            y: self.y.shr(rhs),
1496            z: self.z.shr(rhs),
1497        }
1498    }
1499}
1500
1501impl Shl<u8> for U8Vec3 {
1502    type Output = Self;
1503    #[inline]
1504    fn shl(self, rhs: u8) -> Self::Output {
1505        Self {
1506            x: self.x.shl(rhs),
1507            y: self.y.shl(rhs),
1508            z: self.z.shl(rhs),
1509        }
1510    }
1511}
1512
1513impl Shr<u8> for U8Vec3 {
1514    type Output = Self;
1515    #[inline]
1516    fn shr(self, rhs: u8) -> Self::Output {
1517        Self {
1518            x: self.x.shr(rhs),
1519            y: self.y.shr(rhs),
1520            z: self.z.shr(rhs),
1521        }
1522    }
1523}
1524
1525impl Shl<u16> for U8Vec3 {
1526    type Output = Self;
1527    #[inline]
1528    fn shl(self, rhs: u16) -> Self::Output {
1529        Self {
1530            x: self.x.shl(rhs),
1531            y: self.y.shl(rhs),
1532            z: self.z.shl(rhs),
1533        }
1534    }
1535}
1536
1537impl Shr<u16> for U8Vec3 {
1538    type Output = Self;
1539    #[inline]
1540    fn shr(self, rhs: u16) -> Self::Output {
1541        Self {
1542            x: self.x.shr(rhs),
1543            y: self.y.shr(rhs),
1544            z: self.z.shr(rhs),
1545        }
1546    }
1547}
1548
1549impl Shl<u32> for U8Vec3 {
1550    type Output = Self;
1551    #[inline]
1552    fn shl(self, rhs: u32) -> Self::Output {
1553        Self {
1554            x: self.x.shl(rhs),
1555            y: self.y.shl(rhs),
1556            z: self.z.shl(rhs),
1557        }
1558    }
1559}
1560
1561impl Shr<u32> for U8Vec3 {
1562    type Output = Self;
1563    #[inline]
1564    fn shr(self, rhs: u32) -> Self::Output {
1565        Self {
1566            x: self.x.shr(rhs),
1567            y: self.y.shr(rhs),
1568            z: self.z.shr(rhs),
1569        }
1570    }
1571}
1572
1573impl Shl<u64> for U8Vec3 {
1574    type Output = Self;
1575    #[inline]
1576    fn shl(self, rhs: u64) -> Self::Output {
1577        Self {
1578            x: self.x.shl(rhs),
1579            y: self.y.shl(rhs),
1580            z: self.z.shl(rhs),
1581        }
1582    }
1583}
1584
1585impl Shr<u64> for U8Vec3 {
1586    type Output = Self;
1587    #[inline]
1588    fn shr(self, rhs: u64) -> Self::Output {
1589        Self {
1590            x: self.x.shr(rhs),
1591            y: self.y.shr(rhs),
1592            z: self.z.shr(rhs),
1593        }
1594    }
1595}
1596
1597impl Shl<crate::IVec3> for U8Vec3 {
1598    type Output = Self;
1599    #[inline]
1600    fn shl(self, rhs: crate::IVec3) -> Self::Output {
1601        Self {
1602            x: self.x.shl(rhs.x),
1603            y: self.y.shl(rhs.y),
1604            z: self.z.shl(rhs.z),
1605        }
1606    }
1607}
1608
1609impl Shr<crate::IVec3> for U8Vec3 {
1610    type Output = Self;
1611    #[inline]
1612    fn shr(self, rhs: crate::IVec3) -> Self::Output {
1613        Self {
1614            x: self.x.shr(rhs.x),
1615            y: self.y.shr(rhs.y),
1616            z: self.z.shr(rhs.z),
1617        }
1618    }
1619}
1620
1621impl Shl<crate::UVec3> for U8Vec3 {
1622    type Output = Self;
1623    #[inline]
1624    fn shl(self, rhs: crate::UVec3) -> Self::Output {
1625        Self {
1626            x: self.x.shl(rhs.x),
1627            y: self.y.shl(rhs.y),
1628            z: self.z.shl(rhs.z),
1629        }
1630    }
1631}
1632
1633impl Shr<crate::UVec3> for U8Vec3 {
1634    type Output = Self;
1635    #[inline]
1636    fn shr(self, rhs: crate::UVec3) -> Self::Output {
1637        Self {
1638            x: self.x.shr(rhs.x),
1639            y: self.y.shr(rhs.y),
1640            z: self.z.shr(rhs.z),
1641        }
1642    }
1643}
1644
1645impl Index<usize> for U8Vec3 {
1646    type Output = u8;
1647    #[inline]
1648    fn index(&self, index: usize) -> &Self::Output {
1649        match index {
1650            0 => &self.x,
1651            1 => &self.y,
1652            2 => &self.z,
1653            _ => panic!("index out of bounds"),
1654        }
1655    }
1656}
1657
1658impl IndexMut<usize> for U8Vec3 {
1659    #[inline]
1660    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1661        match index {
1662            0 => &mut self.x,
1663            1 => &mut self.y,
1664            2 => &mut self.z,
1665            _ => panic!("index out of bounds"),
1666        }
1667    }
1668}
1669
1670impl fmt::Display for U8Vec3 {
1671    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1672        write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
1673    }
1674}
1675
1676impl fmt::Debug for U8Vec3 {
1677    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1678        fmt.debug_tuple(stringify!(U8Vec3))
1679            .field(&self.x)
1680            .field(&self.y)
1681            .field(&self.z)
1682            .finish()
1683    }
1684}
1685
1686impl From<[u8; 3]> for U8Vec3 {
1687    #[inline]
1688    fn from(a: [u8; 3]) -> Self {
1689        Self::new(a[0], a[1], a[2])
1690    }
1691}
1692
1693impl From<U8Vec3> for [u8; 3] {
1694    #[inline]
1695    fn from(v: U8Vec3) -> Self {
1696        [v.x, v.y, v.z]
1697    }
1698}
1699
1700impl From<(u8, u8, u8)> for U8Vec3 {
1701    #[inline]
1702    fn from(t: (u8, u8, u8)) -> Self {
1703        Self::new(t.0, t.1, t.2)
1704    }
1705}
1706
1707impl From<U8Vec3> for (u8, u8, u8) {
1708    #[inline]
1709    fn from(v: U8Vec3) -> Self {
1710        (v.x, v.y, v.z)
1711    }
1712}
1713
1714impl From<(U8Vec2, u8)> for U8Vec3 {
1715    #[inline]
1716    fn from((v, z): (U8Vec2, u8)) -> Self {
1717        Self::new(v.x, v.y, z)
1718    }
1719}
1720
1721impl TryFrom<I8Vec3> for U8Vec3 {
1722    type Error = core::num::TryFromIntError;
1723
1724    #[inline]
1725    fn try_from(v: I8Vec3) -> Result<Self, Self::Error> {
1726        Ok(Self::new(
1727            u8::try_from(v.x)?,
1728            u8::try_from(v.y)?,
1729            u8::try_from(v.z)?,
1730        ))
1731    }
1732}
1733
1734impl TryFrom<I16Vec3> for U8Vec3 {
1735    type Error = core::num::TryFromIntError;
1736
1737    #[inline]
1738    fn try_from(v: I16Vec3) -> Result<Self, Self::Error> {
1739        Ok(Self::new(
1740            u8::try_from(v.x)?,
1741            u8::try_from(v.y)?,
1742            u8::try_from(v.z)?,
1743        ))
1744    }
1745}
1746
1747impl TryFrom<U16Vec3> for U8Vec3 {
1748    type Error = core::num::TryFromIntError;
1749
1750    #[inline]
1751    fn try_from(v: U16Vec3) -> Result<Self, Self::Error> {
1752        Ok(Self::new(
1753            u8::try_from(v.x)?,
1754            u8::try_from(v.y)?,
1755            u8::try_from(v.z)?,
1756        ))
1757    }
1758}
1759
1760impl TryFrom<IVec3> for U8Vec3 {
1761    type Error = core::num::TryFromIntError;
1762
1763    #[inline]
1764    fn try_from(v: IVec3) -> Result<Self, Self::Error> {
1765        Ok(Self::new(
1766            u8::try_from(v.x)?,
1767            u8::try_from(v.y)?,
1768            u8::try_from(v.z)?,
1769        ))
1770    }
1771}
1772
1773impl TryFrom<UVec3> for U8Vec3 {
1774    type Error = core::num::TryFromIntError;
1775
1776    #[inline]
1777    fn try_from(v: UVec3) -> Result<Self, Self::Error> {
1778        Ok(Self::new(
1779            u8::try_from(v.x)?,
1780            u8::try_from(v.y)?,
1781            u8::try_from(v.z)?,
1782        ))
1783    }
1784}
1785
1786impl TryFrom<I64Vec3> for U8Vec3 {
1787    type Error = core::num::TryFromIntError;
1788
1789    #[inline]
1790    fn try_from(v: I64Vec3) -> Result<Self, Self::Error> {
1791        Ok(Self::new(
1792            u8::try_from(v.x)?,
1793            u8::try_from(v.y)?,
1794            u8::try_from(v.z)?,
1795        ))
1796    }
1797}
1798
1799impl TryFrom<U64Vec3> for U8Vec3 {
1800    type Error = core::num::TryFromIntError;
1801
1802    #[inline]
1803    fn try_from(v: U64Vec3) -> Result<Self, Self::Error> {
1804        Ok(Self::new(
1805            u8::try_from(v.x)?,
1806            u8::try_from(v.y)?,
1807            u8::try_from(v.z)?,
1808        ))
1809    }
1810}
1811
1812impl From<BVec3> for U8Vec3 {
1813    #[inline]
1814    fn from(v: BVec3) -> Self {
1815        Self::new(u8::from(v.x), u8::from(v.y), u8::from(v.z))
1816    }
1817}
1818
1819impl From<BVec3A> for U8Vec3 {
1820    #[inline]
1821    fn from(v: BVec3A) -> Self {
1822        let bool_array: [bool; 3] = v.into();
1823        Self::new(
1824            u8::from(bool_array[0]),
1825            u8::from(bool_array[1]),
1826            u8::from(bool_array[2]),
1827        )
1828    }
1829}