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