[go: up one dir, main page]

glam/i8/
i8vec3.rs

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