1#[cfg(not(feature = "scalar-math"))]
4use crate::BVec4A;
5use crate::{
6 BVec4, I16Vec4, I64Vec4, I8Vec2, I8Vec3, IVec4, U16Vec4, U64Vec4, U8Vec4, USizeVec4, UVec4,
7};
8
9use core::fmt;
10use core::iter::{Product, Sum};
11use core::{f32, ops::*};
12
13#[inline(always)]
15#[must_use]
16pub const fn i8vec4(x: i8, y: i8, z: i8, w: i8) -> I8Vec4 {
17 I8Vec4::new(x, y, z, w)
18}
19
20#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
22#[derive(Clone, Copy, PartialEq, Eq)]
23#[cfg_attr(feature = "cuda", repr(align(4)))]
24#[cfg_attr(not(target_arch = "spirv"), repr(C))]
25#[cfg_attr(target_arch = "spirv", repr(simd))]
26pub struct I8Vec4 {
27 pub x: i8,
28 pub y: i8,
29 pub z: i8,
30 pub w: i8,
31}
32
33impl I8Vec4 {
34 pub const ZERO: Self = Self::splat(0);
36
37 pub const ONE: Self = Self::splat(1);
39
40 pub const NEG_ONE: Self = Self::splat(-1);
42
43 pub const MIN: Self = Self::splat(i8::MIN);
45
46 pub const MAX: Self = Self::splat(i8::MAX);
48
49 pub const X: Self = Self::new(1, 0, 0, 0);
51
52 pub const Y: Self = Self::new(0, 1, 0, 0);
54
55 pub const Z: Self = Self::new(0, 0, 1, 0);
57
58 pub const W: Self = Self::new(0, 0, 0, 1);
60
61 pub const NEG_X: Self = Self::new(-1, 0, 0, 0);
63
64 pub const NEG_Y: Self = Self::new(0, -1, 0, 0);
66
67 pub const NEG_Z: Self = Self::new(0, 0, -1, 0);
69
70 pub const NEG_W: Self = Self::new(0, 0, 0, -1);
72
73 pub const AXES: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
75
76 #[inline(always)]
78 #[must_use]
79 pub const fn new(x: i8, y: i8, z: i8, w: i8) -> Self {
80 Self { x, y, z, w }
81 }
82
83 #[inline]
85 #[must_use]
86 pub const fn splat(v: i8) -> Self {
87 Self {
88 x: v,
89
90 y: v,
91
92 z: v,
93
94 w: v,
95 }
96 }
97
98 #[inline]
100 #[must_use]
101 pub fn map<F>(self, f: F) -> Self
102 where
103 F: Fn(i8) -> i8,
104 {
105 Self::new(f(self.x), f(self.y), f(self.z), f(self.w))
106 }
107
108 #[inline]
114 #[must_use]
115 pub fn select(mask: BVec4, if_true: Self, if_false: Self) -> Self {
116 Self {
117 x: if mask.test(0) { if_true.x } else { if_false.x },
118 y: if mask.test(1) { if_true.y } else { if_false.y },
119 z: if mask.test(2) { if_true.z } else { if_false.z },
120 w: if mask.test(3) { if_true.w } else { if_false.w },
121 }
122 }
123
124 #[inline]
126 #[must_use]
127 pub const fn from_array(a: [i8; 4]) -> Self {
128 Self::new(a[0], a[1], a[2], a[3])
129 }
130
131 #[inline]
133 #[must_use]
134 pub const fn to_array(&self) -> [i8; 4] {
135 [self.x, self.y, self.z, self.w]
136 }
137
138 #[inline]
144 #[must_use]
145 pub const fn from_slice(slice: &[i8]) -> Self {
146 assert!(slice.len() >= 4);
147 Self::new(slice[0], slice[1], slice[2], slice[3])
148 }
149
150 #[inline]
156 pub fn write_to_slice(self, slice: &mut [i8]) {
157 slice[..4].copy_from_slice(&self.to_array());
158 }
159
160 #[inline]
164 #[must_use]
165 pub fn truncate(self) -> I8Vec3 {
166 use crate::swizzles::Vec4Swizzles;
167 self.xyz()
168 }
169
170 #[inline]
172 #[must_use]
173 pub fn with_x(mut self, x: i8) -> Self {
174 self.x = x;
175 self
176 }
177
178 #[inline]
180 #[must_use]
181 pub fn with_y(mut self, y: i8) -> Self {
182 self.y = y;
183 self
184 }
185
186 #[inline]
188 #[must_use]
189 pub fn with_z(mut self, z: i8) -> Self {
190 self.z = z;
191 self
192 }
193
194 #[inline]
196 #[must_use]
197 pub fn with_w(mut self, w: i8) -> Self {
198 self.w = w;
199 self
200 }
201
202 #[inline]
204 #[must_use]
205 pub fn dot(self, rhs: Self) -> i8 {
206 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) + (self.w * rhs.w)
207 }
208
209 #[inline]
211 #[must_use]
212 pub fn dot_into_vec(self, rhs: Self) -> Self {
213 Self::splat(self.dot(rhs))
214 }
215
216 #[inline]
220 #[must_use]
221 pub fn min(self, rhs: Self) -> Self {
222 Self {
223 x: self.x.min(rhs.x),
224 y: self.y.min(rhs.y),
225 z: self.z.min(rhs.z),
226 w: self.w.min(rhs.w),
227 }
228 }
229
230 #[inline]
234 #[must_use]
235 pub fn max(self, rhs: Self) -> Self {
236 Self {
237 x: self.x.max(rhs.x),
238 y: self.y.max(rhs.y),
239 z: self.z.max(rhs.z),
240 w: self.w.max(rhs.w),
241 }
242 }
243
244 #[inline]
252 #[must_use]
253 pub fn clamp(self, min: Self, max: Self) -> Self {
254 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
255 self.max(min).min(max)
256 }
257
258 #[inline]
262 #[must_use]
263 pub fn min_element(self) -> i8 {
264 self.x.min(self.y.min(self.z.min(self.w)))
265 }
266
267 #[inline]
271 #[must_use]
272 pub fn max_element(self) -> i8 {
273 self.x.max(self.y.max(self.z.max(self.w)))
274 }
275
276 #[doc(alias = "argmin")]
278 #[inline]
279 #[must_use]
280 pub fn min_position(self) -> usize {
281 let mut min = self.x;
282 let mut index = 0;
283 if self.y < min {
284 min = self.y;
285 index = 1;
286 }
287 if self.z < min {
288 min = self.z;
289 index = 2;
290 }
291 if self.w < min {
292 index = 3;
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 max = self.z;
310 index = 2;
311 }
312 if self.w > max {
313 index = 3;
314 }
315 index
316 }
317
318 #[inline]
322 #[must_use]
323 pub fn element_sum(self) -> i8 {
324 self.x + self.y + self.z + self.w
325 }
326
327 #[inline]
331 #[must_use]
332 pub fn element_product(self) -> i8 {
333 self.x * self.y * self.z * self.w
334 }
335
336 #[inline]
342 #[must_use]
343 pub fn cmpeq(self, rhs: Self) -> BVec4 {
344 BVec4::new(
345 self.x.eq(&rhs.x),
346 self.y.eq(&rhs.y),
347 self.z.eq(&rhs.z),
348 self.w.eq(&rhs.w),
349 )
350 }
351
352 #[inline]
358 #[must_use]
359 pub fn cmpne(self, rhs: Self) -> BVec4 {
360 BVec4::new(
361 self.x.ne(&rhs.x),
362 self.y.ne(&rhs.y),
363 self.z.ne(&rhs.z),
364 self.w.ne(&rhs.w),
365 )
366 }
367
368 #[inline]
374 #[must_use]
375 pub fn cmpge(self, rhs: Self) -> BVec4 {
376 BVec4::new(
377 self.x.ge(&rhs.x),
378 self.y.ge(&rhs.y),
379 self.z.ge(&rhs.z),
380 self.w.ge(&rhs.w),
381 )
382 }
383
384 #[inline]
390 #[must_use]
391 pub fn cmpgt(self, rhs: Self) -> BVec4 {
392 BVec4::new(
393 self.x.gt(&rhs.x),
394 self.y.gt(&rhs.y),
395 self.z.gt(&rhs.z),
396 self.w.gt(&rhs.w),
397 )
398 }
399
400 #[inline]
406 #[must_use]
407 pub fn cmple(self, rhs: Self) -> BVec4 {
408 BVec4::new(
409 self.x.le(&rhs.x),
410 self.y.le(&rhs.y),
411 self.z.le(&rhs.z),
412 self.w.le(&rhs.w),
413 )
414 }
415
416 #[inline]
422 #[must_use]
423 pub fn cmplt(self, rhs: Self) -> BVec4 {
424 BVec4::new(
425 self.x.lt(&rhs.x),
426 self.y.lt(&rhs.y),
427 self.z.lt(&rhs.z),
428 self.w.lt(&rhs.w),
429 )
430 }
431
432 #[inline]
434 #[must_use]
435 pub fn abs(self) -> Self {
436 Self {
437 x: self.x.abs(),
438 y: self.y.abs(),
439 z: self.z.abs(),
440 w: self.w.abs(),
441 }
442 }
443
444 #[inline]
450 #[must_use]
451 pub fn signum(self) -> Self {
452 Self {
453 x: self.x.signum(),
454 y: self.y.signum(),
455 z: self.z.signum(),
456 w: self.w.signum(),
457 }
458 }
459
460 #[inline]
465 #[must_use]
466 pub fn is_negative_bitmask(self) -> u32 {
467 (self.x.is_negative() as u32)
468 | ((self.y.is_negative() as u32) << 1)
469 | ((self.z.is_negative() as u32) << 2)
470 | ((self.w.is_negative() as u32) << 3)
471 }
472
473 #[doc(alias = "magnitude2")]
475 #[inline]
476 #[must_use]
477 pub fn length_squared(self) -> i8 {
478 self.dot(self)
479 }
480
481 #[inline]
483 #[must_use]
484 pub fn distance_squared(self, rhs: Self) -> i8 {
485 (self - rhs).length_squared()
486 }
487
488 #[inline]
493 #[must_use]
494 pub fn div_euclid(self, rhs: Self) -> Self {
495 Self::new(
496 self.x.div_euclid(rhs.x),
497 self.y.div_euclid(rhs.y),
498 self.z.div_euclid(rhs.z),
499 self.w.div_euclid(rhs.w),
500 )
501 }
502
503 #[inline]
510 #[must_use]
511 pub fn rem_euclid(self, rhs: Self) -> Self {
512 Self::new(
513 self.x.rem_euclid(rhs.x),
514 self.y.rem_euclid(rhs.y),
515 self.z.rem_euclid(rhs.z),
516 self.w.rem_euclid(rhs.w),
517 )
518 }
519
520 #[inline]
529 #[must_use]
530 pub fn manhattan_distance(self, other: Self) -> u8 {
531 self.x.abs_diff(other.x)
532 + self.y.abs_diff(other.y)
533 + self.z.abs_diff(other.z)
534 + self.w.abs_diff(other.w)
535 }
536
537 #[inline]
543 #[must_use]
544 pub fn checked_manhattan_distance(self, other: Self) -> Option<u8> {
545 let d = self.x.abs_diff(other.x);
546 let d = d.checked_add(self.y.abs_diff(other.y))?;
547 let d = d.checked_add(self.z.abs_diff(other.z))?;
548 d.checked_add(self.w.abs_diff(other.w))
549 }
550
551 #[inline]
555 #[must_use]
556 pub fn chebyshev_distance(self, other: Self) -> u8 {
557 [
559 self.x.abs_diff(other.x),
560 self.y.abs_diff(other.y),
561 self.z.abs_diff(other.z),
562 self.w.abs_diff(other.w),
563 ]
564 .into_iter()
565 .max()
566 .unwrap()
567 }
568
569 #[inline]
571 #[must_use]
572 pub fn as_vec4(&self) -> crate::Vec4 {
573 crate::Vec4::new(self.x as f32, self.y as f32, self.z as f32, self.w as f32)
574 }
575
576 #[inline]
578 #[must_use]
579 pub fn as_dvec4(&self) -> crate::DVec4 {
580 crate::DVec4::new(self.x as f64, self.y as f64, self.z as f64, self.w as f64)
581 }
582
583 #[inline]
585 #[must_use]
586 pub fn as_u8vec4(&self) -> crate::U8Vec4 {
587 crate::U8Vec4::new(self.x as u8, self.y as u8, self.z as u8, self.w as u8)
588 }
589
590 #[inline]
592 #[must_use]
593 pub fn as_i16vec4(&self) -> crate::I16Vec4 {
594 crate::I16Vec4::new(self.x as i16, self.y as i16, self.z as i16, self.w as i16)
595 }
596
597 #[inline]
599 #[must_use]
600 pub fn as_u16vec4(&self) -> crate::U16Vec4 {
601 crate::U16Vec4::new(self.x as u16, self.y as u16, self.z as u16, self.w as u16)
602 }
603
604 #[inline]
606 #[must_use]
607 pub fn as_ivec4(&self) -> crate::IVec4 {
608 crate::IVec4::new(self.x as i32, self.y as i32, self.z as i32, self.w as i32)
609 }
610
611 #[inline]
613 #[must_use]
614 pub fn as_uvec4(&self) -> crate::UVec4 {
615 crate::UVec4::new(self.x as u32, self.y as u32, self.z as u32, self.w as u32)
616 }
617
618 #[inline]
620 #[must_use]
621 pub fn as_i64vec4(&self) -> crate::I64Vec4 {
622 crate::I64Vec4::new(self.x as i64, self.y as i64, self.z as i64, self.w as i64)
623 }
624
625 #[inline]
627 #[must_use]
628 pub fn as_u64vec4(&self) -> crate::U64Vec4 {
629 crate::U64Vec4::new(self.x as u64, self.y as u64, self.z as u64, self.w as u64)
630 }
631
632 #[inline]
634 #[must_use]
635 pub fn as_usizevec4(&self) -> crate::USizeVec4 {
636 crate::USizeVec4::new(
637 self.x as usize,
638 self.y as usize,
639 self.z as usize,
640 self.w as usize,
641 )
642 }
643
644 #[inline]
648 #[must_use]
649 pub const fn checked_add(self, rhs: Self) -> Option<Self> {
650 let x = match self.x.checked_add(rhs.x) {
651 Some(v) => v,
652 None => return None,
653 };
654 let y = match self.y.checked_add(rhs.y) {
655 Some(v) => v,
656 None => return None,
657 };
658 let z = match self.z.checked_add(rhs.z) {
659 Some(v) => v,
660 None => return None,
661 };
662 let w = match self.w.checked_add(rhs.w) {
663 Some(v) => v,
664 None => return None,
665 };
666
667 Some(Self { x, y, z, w })
668 }
669
670 #[inline]
674 #[must_use]
675 pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
676 let x = match self.x.checked_sub(rhs.x) {
677 Some(v) => v,
678 None => return None,
679 };
680 let y = match self.y.checked_sub(rhs.y) {
681 Some(v) => v,
682 None => return None,
683 };
684 let z = match self.z.checked_sub(rhs.z) {
685 Some(v) => v,
686 None => return None,
687 };
688 let w = match self.w.checked_sub(rhs.w) {
689 Some(v) => v,
690 None => return None,
691 };
692
693 Some(Self { x, y, z, w })
694 }
695
696 #[inline]
700 #[must_use]
701 pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
702 let x = match self.x.checked_mul(rhs.x) {
703 Some(v) => v,
704 None => return None,
705 };
706 let y = match self.y.checked_mul(rhs.y) {
707 Some(v) => v,
708 None => return None,
709 };
710 let z = match self.z.checked_mul(rhs.z) {
711 Some(v) => v,
712 None => return None,
713 };
714 let w = match self.w.checked_mul(rhs.w) {
715 Some(v) => v,
716 None => return None,
717 };
718
719 Some(Self { x, y, z, w })
720 }
721
722 #[inline]
726 #[must_use]
727 pub const fn checked_div(self, rhs: Self) -> Option<Self> {
728 let x = match self.x.checked_div(rhs.x) {
729 Some(v) => v,
730 None => return None,
731 };
732 let y = match self.y.checked_div(rhs.y) {
733 Some(v) => v,
734 None => return None,
735 };
736 let z = match self.z.checked_div(rhs.z) {
737 Some(v) => v,
738 None => return None,
739 };
740 let w = match self.w.checked_div(rhs.w) {
741 Some(v) => v,
742 None => return None,
743 };
744
745 Some(Self { x, y, z, w })
746 }
747
748 #[inline]
752 #[must_use]
753 pub const fn wrapping_add(self, rhs: Self) -> Self {
754 Self {
755 x: self.x.wrapping_add(rhs.x),
756 y: self.y.wrapping_add(rhs.y),
757 z: self.z.wrapping_add(rhs.z),
758 w: self.w.wrapping_add(rhs.w),
759 }
760 }
761
762 #[inline]
766 #[must_use]
767 pub const fn wrapping_sub(self, rhs: Self) -> Self {
768 Self {
769 x: self.x.wrapping_sub(rhs.x),
770 y: self.y.wrapping_sub(rhs.y),
771 z: self.z.wrapping_sub(rhs.z),
772 w: self.w.wrapping_sub(rhs.w),
773 }
774 }
775
776 #[inline]
780 #[must_use]
781 pub const fn wrapping_mul(self, rhs: Self) -> Self {
782 Self {
783 x: self.x.wrapping_mul(rhs.x),
784 y: self.y.wrapping_mul(rhs.y),
785 z: self.z.wrapping_mul(rhs.z),
786 w: self.w.wrapping_mul(rhs.w),
787 }
788 }
789
790 #[inline]
794 #[must_use]
795 pub const fn wrapping_div(self, rhs: Self) -> Self {
796 Self {
797 x: self.x.wrapping_div(rhs.x),
798 y: self.y.wrapping_div(rhs.y),
799 z: self.z.wrapping_div(rhs.z),
800 w: self.w.wrapping_div(rhs.w),
801 }
802 }
803
804 #[inline]
808 #[must_use]
809 pub const fn saturating_add(self, rhs: Self) -> Self {
810 Self {
811 x: self.x.saturating_add(rhs.x),
812 y: self.y.saturating_add(rhs.y),
813 z: self.z.saturating_add(rhs.z),
814 w: self.w.saturating_add(rhs.w),
815 }
816 }
817
818 #[inline]
822 #[must_use]
823 pub const fn saturating_sub(self, rhs: Self) -> Self {
824 Self {
825 x: self.x.saturating_sub(rhs.x),
826 y: self.y.saturating_sub(rhs.y),
827 z: self.z.saturating_sub(rhs.z),
828 w: self.w.saturating_sub(rhs.w),
829 }
830 }
831
832 #[inline]
836 #[must_use]
837 pub const fn saturating_mul(self, rhs: Self) -> Self {
838 Self {
839 x: self.x.saturating_mul(rhs.x),
840 y: self.y.saturating_mul(rhs.y),
841 z: self.z.saturating_mul(rhs.z),
842 w: self.w.saturating_mul(rhs.w),
843 }
844 }
845
846 #[inline]
850 #[must_use]
851 pub const fn saturating_div(self, rhs: Self) -> Self {
852 Self {
853 x: self.x.saturating_div(rhs.x),
854 y: self.y.saturating_div(rhs.y),
855 z: self.z.saturating_div(rhs.z),
856 w: self.w.saturating_div(rhs.w),
857 }
858 }
859
860 #[inline]
864 #[must_use]
865 pub const fn checked_add_unsigned(self, rhs: U8Vec4) -> Option<Self> {
866 let x = match self.x.checked_add_unsigned(rhs.x) {
867 Some(v) => v,
868 None => return None,
869 };
870 let y = match self.y.checked_add_unsigned(rhs.y) {
871 Some(v) => v,
872 None => return None,
873 };
874 let z = match self.z.checked_add_unsigned(rhs.z) {
875 Some(v) => v,
876 None => return None,
877 };
878 let w = match self.w.checked_add_unsigned(rhs.w) {
879 Some(v) => v,
880 None => return None,
881 };
882
883 Some(Self { x, y, z, w })
884 }
885
886 #[inline]
890 #[must_use]
891 pub const fn checked_sub_unsigned(self, rhs: U8Vec4) -> Option<Self> {
892 let x = match self.x.checked_sub_unsigned(rhs.x) {
893 Some(v) => v,
894 None => return None,
895 };
896 let y = match self.y.checked_sub_unsigned(rhs.y) {
897 Some(v) => v,
898 None => return None,
899 };
900 let z = match self.z.checked_sub_unsigned(rhs.z) {
901 Some(v) => v,
902 None => return None,
903 };
904 let w = match self.w.checked_sub_unsigned(rhs.w) {
905 Some(v) => v,
906 None => return None,
907 };
908
909 Some(Self { x, y, z, w })
910 }
911
912 #[inline]
916 #[must_use]
917 pub const fn wrapping_add_unsigned(self, rhs: U8Vec4) -> Self {
918 Self {
919 x: self.x.wrapping_add_unsigned(rhs.x),
920 y: self.y.wrapping_add_unsigned(rhs.y),
921 z: self.z.wrapping_add_unsigned(rhs.z),
922 w: self.w.wrapping_add_unsigned(rhs.w),
923 }
924 }
925
926 #[inline]
930 #[must_use]
931 pub const fn wrapping_sub_unsigned(self, rhs: U8Vec4) -> Self {
932 Self {
933 x: self.x.wrapping_sub_unsigned(rhs.x),
934 y: self.y.wrapping_sub_unsigned(rhs.y),
935 z: self.z.wrapping_sub_unsigned(rhs.z),
936 w: self.w.wrapping_sub_unsigned(rhs.w),
937 }
938 }
939
940 #[inline]
944 #[must_use]
945 pub const fn saturating_add_unsigned(self, rhs: U8Vec4) -> Self {
946 Self {
947 x: self.x.saturating_add_unsigned(rhs.x),
948 y: self.y.saturating_add_unsigned(rhs.y),
949 z: self.z.saturating_add_unsigned(rhs.z),
950 w: self.w.saturating_add_unsigned(rhs.w),
951 }
952 }
953
954 #[inline]
958 #[must_use]
959 pub const fn saturating_sub_unsigned(self, rhs: U8Vec4) -> Self {
960 Self {
961 x: self.x.saturating_sub_unsigned(rhs.x),
962 y: self.y.saturating_sub_unsigned(rhs.y),
963 z: self.z.saturating_sub_unsigned(rhs.z),
964 w: self.w.saturating_sub_unsigned(rhs.w),
965 }
966 }
967}
968
969impl Default for I8Vec4 {
970 #[inline(always)]
971 fn default() -> Self {
972 Self::ZERO
973 }
974}
975
976impl Div<I8Vec4> for I8Vec4 {
977 type Output = Self;
978 #[inline]
979 fn div(self, rhs: Self) -> Self {
980 Self {
981 x: self.x.div(rhs.x),
982 y: self.y.div(rhs.y),
983 z: self.z.div(rhs.z),
984 w: self.w.div(rhs.w),
985 }
986 }
987}
988
989impl Div<&I8Vec4> for I8Vec4 {
990 type Output = I8Vec4;
991 #[inline]
992 fn div(self, rhs: &I8Vec4) -> I8Vec4 {
993 self.div(*rhs)
994 }
995}
996
997impl Div<&I8Vec4> for &I8Vec4 {
998 type Output = I8Vec4;
999 #[inline]
1000 fn div(self, rhs: &I8Vec4) -> I8Vec4 {
1001 (*self).div(*rhs)
1002 }
1003}
1004
1005impl Div<I8Vec4> for &I8Vec4 {
1006 type Output = I8Vec4;
1007 #[inline]
1008 fn div(self, rhs: I8Vec4) -> I8Vec4 {
1009 (*self).div(rhs)
1010 }
1011}
1012
1013impl DivAssign<I8Vec4> for I8Vec4 {
1014 #[inline]
1015 fn div_assign(&mut self, rhs: Self) {
1016 self.x.div_assign(rhs.x);
1017 self.y.div_assign(rhs.y);
1018 self.z.div_assign(rhs.z);
1019 self.w.div_assign(rhs.w);
1020 }
1021}
1022
1023impl DivAssign<&I8Vec4> for I8Vec4 {
1024 #[inline]
1025 fn div_assign(&mut self, rhs: &I8Vec4) {
1026 self.div_assign(*rhs)
1027 }
1028}
1029
1030impl Div<i8> for I8Vec4 {
1031 type Output = Self;
1032 #[inline]
1033 fn div(self, rhs: i8) -> Self {
1034 Self {
1035 x: self.x.div(rhs),
1036 y: self.y.div(rhs),
1037 z: self.z.div(rhs),
1038 w: self.w.div(rhs),
1039 }
1040 }
1041}
1042
1043impl Div<&i8> for I8Vec4 {
1044 type Output = I8Vec4;
1045 #[inline]
1046 fn div(self, rhs: &i8) -> I8Vec4 {
1047 self.div(*rhs)
1048 }
1049}
1050
1051impl Div<&i8> for &I8Vec4 {
1052 type Output = I8Vec4;
1053 #[inline]
1054 fn div(self, rhs: &i8) -> I8Vec4 {
1055 (*self).div(*rhs)
1056 }
1057}
1058
1059impl Div<i8> for &I8Vec4 {
1060 type Output = I8Vec4;
1061 #[inline]
1062 fn div(self, rhs: i8) -> I8Vec4 {
1063 (*self).div(rhs)
1064 }
1065}
1066
1067impl DivAssign<i8> for I8Vec4 {
1068 #[inline]
1069 fn div_assign(&mut self, rhs: i8) {
1070 self.x.div_assign(rhs);
1071 self.y.div_assign(rhs);
1072 self.z.div_assign(rhs);
1073 self.w.div_assign(rhs);
1074 }
1075}
1076
1077impl DivAssign<&i8> for I8Vec4 {
1078 #[inline]
1079 fn div_assign(&mut self, rhs: &i8) {
1080 self.div_assign(*rhs)
1081 }
1082}
1083
1084impl Div<I8Vec4> for i8 {
1085 type Output = I8Vec4;
1086 #[inline]
1087 fn div(self, rhs: I8Vec4) -> I8Vec4 {
1088 I8Vec4 {
1089 x: self.div(rhs.x),
1090 y: self.div(rhs.y),
1091 z: self.div(rhs.z),
1092 w: self.div(rhs.w),
1093 }
1094 }
1095}
1096
1097impl Div<&I8Vec4> for i8 {
1098 type Output = I8Vec4;
1099 #[inline]
1100 fn div(self, rhs: &I8Vec4) -> I8Vec4 {
1101 self.div(*rhs)
1102 }
1103}
1104
1105impl Div<&I8Vec4> for &i8 {
1106 type Output = I8Vec4;
1107 #[inline]
1108 fn div(self, rhs: &I8Vec4) -> I8Vec4 {
1109 (*self).div(*rhs)
1110 }
1111}
1112
1113impl Div<I8Vec4> for &i8 {
1114 type Output = I8Vec4;
1115 #[inline]
1116 fn div(self, rhs: I8Vec4) -> I8Vec4 {
1117 (*self).div(rhs)
1118 }
1119}
1120
1121impl Mul<I8Vec4> for I8Vec4 {
1122 type Output = Self;
1123 #[inline]
1124 fn mul(self, rhs: Self) -> Self {
1125 Self {
1126 x: self.x.mul(rhs.x),
1127 y: self.y.mul(rhs.y),
1128 z: self.z.mul(rhs.z),
1129 w: self.w.mul(rhs.w),
1130 }
1131 }
1132}
1133
1134impl Mul<&I8Vec4> for I8Vec4 {
1135 type Output = I8Vec4;
1136 #[inline]
1137 fn mul(self, rhs: &I8Vec4) -> I8Vec4 {
1138 self.mul(*rhs)
1139 }
1140}
1141
1142impl Mul<&I8Vec4> for &I8Vec4 {
1143 type Output = I8Vec4;
1144 #[inline]
1145 fn mul(self, rhs: &I8Vec4) -> I8Vec4 {
1146 (*self).mul(*rhs)
1147 }
1148}
1149
1150impl Mul<I8Vec4> for &I8Vec4 {
1151 type Output = I8Vec4;
1152 #[inline]
1153 fn mul(self, rhs: I8Vec4) -> I8Vec4 {
1154 (*self).mul(rhs)
1155 }
1156}
1157
1158impl MulAssign<I8Vec4> for I8Vec4 {
1159 #[inline]
1160 fn mul_assign(&mut self, rhs: Self) {
1161 self.x.mul_assign(rhs.x);
1162 self.y.mul_assign(rhs.y);
1163 self.z.mul_assign(rhs.z);
1164 self.w.mul_assign(rhs.w);
1165 }
1166}
1167
1168impl MulAssign<&I8Vec4> for I8Vec4 {
1169 #[inline]
1170 fn mul_assign(&mut self, rhs: &I8Vec4) {
1171 self.mul_assign(*rhs)
1172 }
1173}
1174
1175impl Mul<i8> for I8Vec4 {
1176 type Output = Self;
1177 #[inline]
1178 fn mul(self, rhs: i8) -> Self {
1179 Self {
1180 x: self.x.mul(rhs),
1181 y: self.y.mul(rhs),
1182 z: self.z.mul(rhs),
1183 w: self.w.mul(rhs),
1184 }
1185 }
1186}
1187
1188impl Mul<&i8> for I8Vec4 {
1189 type Output = I8Vec4;
1190 #[inline]
1191 fn mul(self, rhs: &i8) -> I8Vec4 {
1192 self.mul(*rhs)
1193 }
1194}
1195
1196impl Mul<&i8> for &I8Vec4 {
1197 type Output = I8Vec4;
1198 #[inline]
1199 fn mul(self, rhs: &i8) -> I8Vec4 {
1200 (*self).mul(*rhs)
1201 }
1202}
1203
1204impl Mul<i8> for &I8Vec4 {
1205 type Output = I8Vec4;
1206 #[inline]
1207 fn mul(self, rhs: i8) -> I8Vec4 {
1208 (*self).mul(rhs)
1209 }
1210}
1211
1212impl MulAssign<i8> for I8Vec4 {
1213 #[inline]
1214 fn mul_assign(&mut self, rhs: i8) {
1215 self.x.mul_assign(rhs);
1216 self.y.mul_assign(rhs);
1217 self.z.mul_assign(rhs);
1218 self.w.mul_assign(rhs);
1219 }
1220}
1221
1222impl MulAssign<&i8> for I8Vec4 {
1223 #[inline]
1224 fn mul_assign(&mut self, rhs: &i8) {
1225 self.mul_assign(*rhs)
1226 }
1227}
1228
1229impl Mul<I8Vec4> for i8 {
1230 type Output = I8Vec4;
1231 #[inline]
1232 fn mul(self, rhs: I8Vec4) -> I8Vec4 {
1233 I8Vec4 {
1234 x: self.mul(rhs.x),
1235 y: self.mul(rhs.y),
1236 z: self.mul(rhs.z),
1237 w: self.mul(rhs.w),
1238 }
1239 }
1240}
1241
1242impl Mul<&I8Vec4> for i8 {
1243 type Output = I8Vec4;
1244 #[inline]
1245 fn mul(self, rhs: &I8Vec4) -> I8Vec4 {
1246 self.mul(*rhs)
1247 }
1248}
1249
1250impl Mul<&I8Vec4> for &i8 {
1251 type Output = I8Vec4;
1252 #[inline]
1253 fn mul(self, rhs: &I8Vec4) -> I8Vec4 {
1254 (*self).mul(*rhs)
1255 }
1256}
1257
1258impl Mul<I8Vec4> for &i8 {
1259 type Output = I8Vec4;
1260 #[inline]
1261 fn mul(self, rhs: I8Vec4) -> I8Vec4 {
1262 (*self).mul(rhs)
1263 }
1264}
1265
1266impl Add<I8Vec4> for I8Vec4 {
1267 type Output = Self;
1268 #[inline]
1269 fn add(self, rhs: Self) -> Self {
1270 Self {
1271 x: self.x.add(rhs.x),
1272 y: self.y.add(rhs.y),
1273 z: self.z.add(rhs.z),
1274 w: self.w.add(rhs.w),
1275 }
1276 }
1277}
1278
1279impl Add<&I8Vec4> for I8Vec4 {
1280 type Output = I8Vec4;
1281 #[inline]
1282 fn add(self, rhs: &I8Vec4) -> I8Vec4 {
1283 self.add(*rhs)
1284 }
1285}
1286
1287impl Add<&I8Vec4> for &I8Vec4 {
1288 type Output = I8Vec4;
1289 #[inline]
1290 fn add(self, rhs: &I8Vec4) -> I8Vec4 {
1291 (*self).add(*rhs)
1292 }
1293}
1294
1295impl Add<I8Vec4> for &I8Vec4 {
1296 type Output = I8Vec4;
1297 #[inline]
1298 fn add(self, rhs: I8Vec4) -> I8Vec4 {
1299 (*self).add(rhs)
1300 }
1301}
1302
1303impl AddAssign<I8Vec4> for I8Vec4 {
1304 #[inline]
1305 fn add_assign(&mut self, rhs: Self) {
1306 self.x.add_assign(rhs.x);
1307 self.y.add_assign(rhs.y);
1308 self.z.add_assign(rhs.z);
1309 self.w.add_assign(rhs.w);
1310 }
1311}
1312
1313impl AddAssign<&I8Vec4> for I8Vec4 {
1314 #[inline]
1315 fn add_assign(&mut self, rhs: &I8Vec4) {
1316 self.add_assign(*rhs)
1317 }
1318}
1319
1320impl Add<i8> for I8Vec4 {
1321 type Output = Self;
1322 #[inline]
1323 fn add(self, rhs: i8) -> Self {
1324 Self {
1325 x: self.x.add(rhs),
1326 y: self.y.add(rhs),
1327 z: self.z.add(rhs),
1328 w: self.w.add(rhs),
1329 }
1330 }
1331}
1332
1333impl Add<&i8> for I8Vec4 {
1334 type Output = I8Vec4;
1335 #[inline]
1336 fn add(self, rhs: &i8) -> I8Vec4 {
1337 self.add(*rhs)
1338 }
1339}
1340
1341impl Add<&i8> for &I8Vec4 {
1342 type Output = I8Vec4;
1343 #[inline]
1344 fn add(self, rhs: &i8) -> I8Vec4 {
1345 (*self).add(*rhs)
1346 }
1347}
1348
1349impl Add<i8> for &I8Vec4 {
1350 type Output = I8Vec4;
1351 #[inline]
1352 fn add(self, rhs: i8) -> I8Vec4 {
1353 (*self).add(rhs)
1354 }
1355}
1356
1357impl AddAssign<i8> for I8Vec4 {
1358 #[inline]
1359 fn add_assign(&mut self, rhs: i8) {
1360 self.x.add_assign(rhs);
1361 self.y.add_assign(rhs);
1362 self.z.add_assign(rhs);
1363 self.w.add_assign(rhs);
1364 }
1365}
1366
1367impl AddAssign<&i8> for I8Vec4 {
1368 #[inline]
1369 fn add_assign(&mut self, rhs: &i8) {
1370 self.add_assign(*rhs)
1371 }
1372}
1373
1374impl Add<I8Vec4> for i8 {
1375 type Output = I8Vec4;
1376 #[inline]
1377 fn add(self, rhs: I8Vec4) -> I8Vec4 {
1378 I8Vec4 {
1379 x: self.add(rhs.x),
1380 y: self.add(rhs.y),
1381 z: self.add(rhs.z),
1382 w: self.add(rhs.w),
1383 }
1384 }
1385}
1386
1387impl Add<&I8Vec4> for i8 {
1388 type Output = I8Vec4;
1389 #[inline]
1390 fn add(self, rhs: &I8Vec4) -> I8Vec4 {
1391 self.add(*rhs)
1392 }
1393}
1394
1395impl Add<&I8Vec4> for &i8 {
1396 type Output = I8Vec4;
1397 #[inline]
1398 fn add(self, rhs: &I8Vec4) -> I8Vec4 {
1399 (*self).add(*rhs)
1400 }
1401}
1402
1403impl Add<I8Vec4> for &i8 {
1404 type Output = I8Vec4;
1405 #[inline]
1406 fn add(self, rhs: I8Vec4) -> I8Vec4 {
1407 (*self).add(rhs)
1408 }
1409}
1410
1411impl Sub<I8Vec4> for I8Vec4 {
1412 type Output = Self;
1413 #[inline]
1414 fn sub(self, rhs: Self) -> Self {
1415 Self {
1416 x: self.x.sub(rhs.x),
1417 y: self.y.sub(rhs.y),
1418 z: self.z.sub(rhs.z),
1419 w: self.w.sub(rhs.w),
1420 }
1421 }
1422}
1423
1424impl Sub<&I8Vec4> for I8Vec4 {
1425 type Output = I8Vec4;
1426 #[inline]
1427 fn sub(self, rhs: &I8Vec4) -> I8Vec4 {
1428 self.sub(*rhs)
1429 }
1430}
1431
1432impl Sub<&I8Vec4> for &I8Vec4 {
1433 type Output = I8Vec4;
1434 #[inline]
1435 fn sub(self, rhs: &I8Vec4) -> I8Vec4 {
1436 (*self).sub(*rhs)
1437 }
1438}
1439
1440impl Sub<I8Vec4> for &I8Vec4 {
1441 type Output = I8Vec4;
1442 #[inline]
1443 fn sub(self, rhs: I8Vec4) -> I8Vec4 {
1444 (*self).sub(rhs)
1445 }
1446}
1447
1448impl SubAssign<I8Vec4> for I8Vec4 {
1449 #[inline]
1450 fn sub_assign(&mut self, rhs: I8Vec4) {
1451 self.x.sub_assign(rhs.x);
1452 self.y.sub_assign(rhs.y);
1453 self.z.sub_assign(rhs.z);
1454 self.w.sub_assign(rhs.w);
1455 }
1456}
1457
1458impl SubAssign<&I8Vec4> for I8Vec4 {
1459 #[inline]
1460 fn sub_assign(&mut self, rhs: &I8Vec4) {
1461 self.sub_assign(*rhs)
1462 }
1463}
1464
1465impl Sub<i8> for I8Vec4 {
1466 type Output = Self;
1467 #[inline]
1468 fn sub(self, rhs: i8) -> Self {
1469 Self {
1470 x: self.x.sub(rhs),
1471 y: self.y.sub(rhs),
1472 z: self.z.sub(rhs),
1473 w: self.w.sub(rhs),
1474 }
1475 }
1476}
1477
1478impl Sub<&i8> for I8Vec4 {
1479 type Output = I8Vec4;
1480 #[inline]
1481 fn sub(self, rhs: &i8) -> I8Vec4 {
1482 self.sub(*rhs)
1483 }
1484}
1485
1486impl Sub<&i8> for &I8Vec4 {
1487 type Output = I8Vec4;
1488 #[inline]
1489 fn sub(self, rhs: &i8) -> I8Vec4 {
1490 (*self).sub(*rhs)
1491 }
1492}
1493
1494impl Sub<i8> for &I8Vec4 {
1495 type Output = I8Vec4;
1496 #[inline]
1497 fn sub(self, rhs: i8) -> I8Vec4 {
1498 (*self).sub(rhs)
1499 }
1500}
1501
1502impl SubAssign<i8> for I8Vec4 {
1503 #[inline]
1504 fn sub_assign(&mut self, rhs: i8) {
1505 self.x.sub_assign(rhs);
1506 self.y.sub_assign(rhs);
1507 self.z.sub_assign(rhs);
1508 self.w.sub_assign(rhs);
1509 }
1510}
1511
1512impl SubAssign<&i8> for I8Vec4 {
1513 #[inline]
1514 fn sub_assign(&mut self, rhs: &i8) {
1515 self.sub_assign(*rhs)
1516 }
1517}
1518
1519impl Sub<I8Vec4> for i8 {
1520 type Output = I8Vec4;
1521 #[inline]
1522 fn sub(self, rhs: I8Vec4) -> I8Vec4 {
1523 I8Vec4 {
1524 x: self.sub(rhs.x),
1525 y: self.sub(rhs.y),
1526 z: self.sub(rhs.z),
1527 w: self.sub(rhs.w),
1528 }
1529 }
1530}
1531
1532impl Sub<&I8Vec4> for i8 {
1533 type Output = I8Vec4;
1534 #[inline]
1535 fn sub(self, rhs: &I8Vec4) -> I8Vec4 {
1536 self.sub(*rhs)
1537 }
1538}
1539
1540impl Sub<&I8Vec4> for &i8 {
1541 type Output = I8Vec4;
1542 #[inline]
1543 fn sub(self, rhs: &I8Vec4) -> I8Vec4 {
1544 (*self).sub(*rhs)
1545 }
1546}
1547
1548impl Sub<I8Vec4> for &i8 {
1549 type Output = I8Vec4;
1550 #[inline]
1551 fn sub(self, rhs: I8Vec4) -> I8Vec4 {
1552 (*self).sub(rhs)
1553 }
1554}
1555
1556impl Rem<I8Vec4> for I8Vec4 {
1557 type Output = Self;
1558 #[inline]
1559 fn rem(self, rhs: Self) -> Self {
1560 Self {
1561 x: self.x.rem(rhs.x),
1562 y: self.y.rem(rhs.y),
1563 z: self.z.rem(rhs.z),
1564 w: self.w.rem(rhs.w),
1565 }
1566 }
1567}
1568
1569impl Rem<&I8Vec4> for I8Vec4 {
1570 type Output = I8Vec4;
1571 #[inline]
1572 fn rem(self, rhs: &I8Vec4) -> I8Vec4 {
1573 self.rem(*rhs)
1574 }
1575}
1576
1577impl Rem<&I8Vec4> for &I8Vec4 {
1578 type Output = I8Vec4;
1579 #[inline]
1580 fn rem(self, rhs: &I8Vec4) -> I8Vec4 {
1581 (*self).rem(*rhs)
1582 }
1583}
1584
1585impl Rem<I8Vec4> for &I8Vec4 {
1586 type Output = I8Vec4;
1587 #[inline]
1588 fn rem(self, rhs: I8Vec4) -> I8Vec4 {
1589 (*self).rem(rhs)
1590 }
1591}
1592
1593impl RemAssign<I8Vec4> for I8Vec4 {
1594 #[inline]
1595 fn rem_assign(&mut self, rhs: Self) {
1596 self.x.rem_assign(rhs.x);
1597 self.y.rem_assign(rhs.y);
1598 self.z.rem_assign(rhs.z);
1599 self.w.rem_assign(rhs.w);
1600 }
1601}
1602
1603impl RemAssign<&I8Vec4> for I8Vec4 {
1604 #[inline]
1605 fn rem_assign(&mut self, rhs: &I8Vec4) {
1606 self.rem_assign(*rhs)
1607 }
1608}
1609
1610impl Rem<i8> for I8Vec4 {
1611 type Output = Self;
1612 #[inline]
1613 fn rem(self, rhs: i8) -> Self {
1614 Self {
1615 x: self.x.rem(rhs),
1616 y: self.y.rem(rhs),
1617 z: self.z.rem(rhs),
1618 w: self.w.rem(rhs),
1619 }
1620 }
1621}
1622
1623impl Rem<&i8> for I8Vec4 {
1624 type Output = I8Vec4;
1625 #[inline]
1626 fn rem(self, rhs: &i8) -> I8Vec4 {
1627 self.rem(*rhs)
1628 }
1629}
1630
1631impl Rem<&i8> for &I8Vec4 {
1632 type Output = I8Vec4;
1633 #[inline]
1634 fn rem(self, rhs: &i8) -> I8Vec4 {
1635 (*self).rem(*rhs)
1636 }
1637}
1638
1639impl Rem<i8> for &I8Vec4 {
1640 type Output = I8Vec4;
1641 #[inline]
1642 fn rem(self, rhs: i8) -> I8Vec4 {
1643 (*self).rem(rhs)
1644 }
1645}
1646
1647impl RemAssign<i8> for I8Vec4 {
1648 #[inline]
1649 fn rem_assign(&mut self, rhs: i8) {
1650 self.x.rem_assign(rhs);
1651 self.y.rem_assign(rhs);
1652 self.z.rem_assign(rhs);
1653 self.w.rem_assign(rhs);
1654 }
1655}
1656
1657impl RemAssign<&i8> for I8Vec4 {
1658 #[inline]
1659 fn rem_assign(&mut self, rhs: &i8) {
1660 self.rem_assign(*rhs)
1661 }
1662}
1663
1664impl Rem<I8Vec4> for i8 {
1665 type Output = I8Vec4;
1666 #[inline]
1667 fn rem(self, rhs: I8Vec4) -> I8Vec4 {
1668 I8Vec4 {
1669 x: self.rem(rhs.x),
1670 y: self.rem(rhs.y),
1671 z: self.rem(rhs.z),
1672 w: self.rem(rhs.w),
1673 }
1674 }
1675}
1676
1677impl Rem<&I8Vec4> for i8 {
1678 type Output = I8Vec4;
1679 #[inline]
1680 fn rem(self, rhs: &I8Vec4) -> I8Vec4 {
1681 self.rem(*rhs)
1682 }
1683}
1684
1685impl Rem<&I8Vec4> for &i8 {
1686 type Output = I8Vec4;
1687 #[inline]
1688 fn rem(self, rhs: &I8Vec4) -> I8Vec4 {
1689 (*self).rem(*rhs)
1690 }
1691}
1692
1693impl Rem<I8Vec4> for &i8 {
1694 type Output = I8Vec4;
1695 #[inline]
1696 fn rem(self, rhs: I8Vec4) -> I8Vec4 {
1697 (*self).rem(rhs)
1698 }
1699}
1700
1701#[cfg(not(target_arch = "spirv"))]
1702impl AsRef<[i8; 4]> for I8Vec4 {
1703 #[inline]
1704 fn as_ref(&self) -> &[i8; 4] {
1705 unsafe { &*(self as *const I8Vec4 as *const [i8; 4]) }
1706 }
1707}
1708
1709#[cfg(not(target_arch = "spirv"))]
1710impl AsMut<[i8; 4]> for I8Vec4 {
1711 #[inline]
1712 fn as_mut(&mut self) -> &mut [i8; 4] {
1713 unsafe { &mut *(self as *mut I8Vec4 as *mut [i8; 4]) }
1714 }
1715}
1716
1717impl Sum for I8Vec4 {
1718 #[inline]
1719 fn sum<I>(iter: I) -> Self
1720 where
1721 I: Iterator<Item = Self>,
1722 {
1723 iter.fold(Self::ZERO, Self::add)
1724 }
1725}
1726
1727impl<'a> Sum<&'a Self> for I8Vec4 {
1728 #[inline]
1729 fn sum<I>(iter: I) -> Self
1730 where
1731 I: Iterator<Item = &'a Self>,
1732 {
1733 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1734 }
1735}
1736
1737impl Product for I8Vec4 {
1738 #[inline]
1739 fn product<I>(iter: I) -> Self
1740 where
1741 I: Iterator<Item = Self>,
1742 {
1743 iter.fold(Self::ONE, Self::mul)
1744 }
1745}
1746
1747impl<'a> Product<&'a Self> for I8Vec4 {
1748 #[inline]
1749 fn product<I>(iter: I) -> Self
1750 where
1751 I: Iterator<Item = &'a Self>,
1752 {
1753 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1754 }
1755}
1756
1757impl Neg for I8Vec4 {
1758 type Output = Self;
1759 #[inline]
1760 fn neg(self) -> Self {
1761 Self {
1762 x: self.x.neg(),
1763 y: self.y.neg(),
1764 z: self.z.neg(),
1765 w: self.w.neg(),
1766 }
1767 }
1768}
1769
1770impl Neg for &I8Vec4 {
1771 type Output = I8Vec4;
1772 #[inline]
1773 fn neg(self) -> I8Vec4 {
1774 (*self).neg()
1775 }
1776}
1777
1778impl Not for I8Vec4 {
1779 type Output = Self;
1780 #[inline]
1781 fn not(self) -> Self::Output {
1782 Self {
1783 x: self.x.not(),
1784 y: self.y.not(),
1785 z: self.z.not(),
1786 w: self.w.not(),
1787 }
1788 }
1789}
1790
1791impl BitAnd for I8Vec4 {
1792 type Output = Self;
1793 #[inline]
1794 fn bitand(self, rhs: Self) -> Self::Output {
1795 Self {
1796 x: self.x.bitand(rhs.x),
1797 y: self.y.bitand(rhs.y),
1798 z: self.z.bitand(rhs.z),
1799 w: self.w.bitand(rhs.w),
1800 }
1801 }
1802}
1803
1804impl BitOr for I8Vec4 {
1805 type Output = Self;
1806 #[inline]
1807 fn bitor(self, rhs: Self) -> Self::Output {
1808 Self {
1809 x: self.x.bitor(rhs.x),
1810 y: self.y.bitor(rhs.y),
1811 z: self.z.bitor(rhs.z),
1812 w: self.w.bitor(rhs.w),
1813 }
1814 }
1815}
1816
1817impl BitXor for I8Vec4 {
1818 type Output = Self;
1819 #[inline]
1820 fn bitxor(self, rhs: Self) -> Self::Output {
1821 Self {
1822 x: self.x.bitxor(rhs.x),
1823 y: self.y.bitxor(rhs.y),
1824 z: self.z.bitxor(rhs.z),
1825 w: self.w.bitxor(rhs.w),
1826 }
1827 }
1828}
1829
1830impl BitAnd<i8> for I8Vec4 {
1831 type Output = Self;
1832 #[inline]
1833 fn bitand(self, rhs: i8) -> Self::Output {
1834 Self {
1835 x: self.x.bitand(rhs),
1836 y: self.y.bitand(rhs),
1837 z: self.z.bitand(rhs),
1838 w: self.w.bitand(rhs),
1839 }
1840 }
1841}
1842
1843impl BitOr<i8> for I8Vec4 {
1844 type Output = Self;
1845 #[inline]
1846 fn bitor(self, rhs: i8) -> Self::Output {
1847 Self {
1848 x: self.x.bitor(rhs),
1849 y: self.y.bitor(rhs),
1850 z: self.z.bitor(rhs),
1851 w: self.w.bitor(rhs),
1852 }
1853 }
1854}
1855
1856impl BitXor<i8> for I8Vec4 {
1857 type Output = Self;
1858 #[inline]
1859 fn bitxor(self, rhs: i8) -> Self::Output {
1860 Self {
1861 x: self.x.bitxor(rhs),
1862 y: self.y.bitxor(rhs),
1863 z: self.z.bitxor(rhs),
1864 w: self.w.bitxor(rhs),
1865 }
1866 }
1867}
1868
1869impl Shl<i8> for I8Vec4 {
1870 type Output = Self;
1871 #[inline]
1872 fn shl(self, rhs: i8) -> Self::Output {
1873 Self {
1874 x: self.x.shl(rhs),
1875 y: self.y.shl(rhs),
1876 z: self.z.shl(rhs),
1877 w: self.w.shl(rhs),
1878 }
1879 }
1880}
1881
1882impl Shr<i8> for I8Vec4 {
1883 type Output = Self;
1884 #[inline]
1885 fn shr(self, rhs: i8) -> Self::Output {
1886 Self {
1887 x: self.x.shr(rhs),
1888 y: self.y.shr(rhs),
1889 z: self.z.shr(rhs),
1890 w: self.w.shr(rhs),
1891 }
1892 }
1893}
1894
1895impl Shl<i16> for I8Vec4 {
1896 type Output = Self;
1897 #[inline]
1898 fn shl(self, rhs: i16) -> Self::Output {
1899 Self {
1900 x: self.x.shl(rhs),
1901 y: self.y.shl(rhs),
1902 z: self.z.shl(rhs),
1903 w: self.w.shl(rhs),
1904 }
1905 }
1906}
1907
1908impl Shr<i16> for I8Vec4 {
1909 type Output = Self;
1910 #[inline]
1911 fn shr(self, rhs: i16) -> Self::Output {
1912 Self {
1913 x: self.x.shr(rhs),
1914 y: self.y.shr(rhs),
1915 z: self.z.shr(rhs),
1916 w: self.w.shr(rhs),
1917 }
1918 }
1919}
1920
1921impl Shl<i32> for I8Vec4 {
1922 type Output = Self;
1923 #[inline]
1924 fn shl(self, rhs: i32) -> Self::Output {
1925 Self {
1926 x: self.x.shl(rhs),
1927 y: self.y.shl(rhs),
1928 z: self.z.shl(rhs),
1929 w: self.w.shl(rhs),
1930 }
1931 }
1932}
1933
1934impl Shr<i32> for I8Vec4 {
1935 type Output = Self;
1936 #[inline]
1937 fn shr(self, rhs: i32) -> Self::Output {
1938 Self {
1939 x: self.x.shr(rhs),
1940 y: self.y.shr(rhs),
1941 z: self.z.shr(rhs),
1942 w: self.w.shr(rhs),
1943 }
1944 }
1945}
1946
1947impl Shl<i64> for I8Vec4 {
1948 type Output = Self;
1949 #[inline]
1950 fn shl(self, rhs: i64) -> Self::Output {
1951 Self {
1952 x: self.x.shl(rhs),
1953 y: self.y.shl(rhs),
1954 z: self.z.shl(rhs),
1955 w: self.w.shl(rhs),
1956 }
1957 }
1958}
1959
1960impl Shr<i64> for I8Vec4 {
1961 type Output = Self;
1962 #[inline]
1963 fn shr(self, rhs: i64) -> Self::Output {
1964 Self {
1965 x: self.x.shr(rhs),
1966 y: self.y.shr(rhs),
1967 z: self.z.shr(rhs),
1968 w: self.w.shr(rhs),
1969 }
1970 }
1971}
1972
1973impl Shl<u8> for I8Vec4 {
1974 type Output = Self;
1975 #[inline]
1976 fn shl(self, rhs: u8) -> Self::Output {
1977 Self {
1978 x: self.x.shl(rhs),
1979 y: self.y.shl(rhs),
1980 z: self.z.shl(rhs),
1981 w: self.w.shl(rhs),
1982 }
1983 }
1984}
1985
1986impl Shr<u8> for I8Vec4 {
1987 type Output = Self;
1988 #[inline]
1989 fn shr(self, rhs: u8) -> Self::Output {
1990 Self {
1991 x: self.x.shr(rhs),
1992 y: self.y.shr(rhs),
1993 z: self.z.shr(rhs),
1994 w: self.w.shr(rhs),
1995 }
1996 }
1997}
1998
1999impl Shl<u16> for I8Vec4 {
2000 type Output = Self;
2001 #[inline]
2002 fn shl(self, rhs: u16) -> Self::Output {
2003 Self {
2004 x: self.x.shl(rhs),
2005 y: self.y.shl(rhs),
2006 z: self.z.shl(rhs),
2007 w: self.w.shl(rhs),
2008 }
2009 }
2010}
2011
2012impl Shr<u16> for I8Vec4 {
2013 type Output = Self;
2014 #[inline]
2015 fn shr(self, rhs: u16) -> Self::Output {
2016 Self {
2017 x: self.x.shr(rhs),
2018 y: self.y.shr(rhs),
2019 z: self.z.shr(rhs),
2020 w: self.w.shr(rhs),
2021 }
2022 }
2023}
2024
2025impl Shl<u32> for I8Vec4 {
2026 type Output = Self;
2027 #[inline]
2028 fn shl(self, rhs: u32) -> Self::Output {
2029 Self {
2030 x: self.x.shl(rhs),
2031 y: self.y.shl(rhs),
2032 z: self.z.shl(rhs),
2033 w: self.w.shl(rhs),
2034 }
2035 }
2036}
2037
2038impl Shr<u32> for I8Vec4 {
2039 type Output = Self;
2040 #[inline]
2041 fn shr(self, rhs: u32) -> Self::Output {
2042 Self {
2043 x: self.x.shr(rhs),
2044 y: self.y.shr(rhs),
2045 z: self.z.shr(rhs),
2046 w: self.w.shr(rhs),
2047 }
2048 }
2049}
2050
2051impl Shl<u64> for I8Vec4 {
2052 type Output = Self;
2053 #[inline]
2054 fn shl(self, rhs: u64) -> Self::Output {
2055 Self {
2056 x: self.x.shl(rhs),
2057 y: self.y.shl(rhs),
2058 z: self.z.shl(rhs),
2059 w: self.w.shl(rhs),
2060 }
2061 }
2062}
2063
2064impl Shr<u64> for I8Vec4 {
2065 type Output = Self;
2066 #[inline]
2067 fn shr(self, rhs: u64) -> Self::Output {
2068 Self {
2069 x: self.x.shr(rhs),
2070 y: self.y.shr(rhs),
2071 z: self.z.shr(rhs),
2072 w: self.w.shr(rhs),
2073 }
2074 }
2075}
2076
2077impl Shl<crate::IVec4> for I8Vec4 {
2078 type Output = Self;
2079 #[inline]
2080 fn shl(self, rhs: crate::IVec4) -> Self::Output {
2081 Self {
2082 x: self.x.shl(rhs.x),
2083 y: self.y.shl(rhs.y),
2084 z: self.z.shl(rhs.z),
2085 w: self.w.shl(rhs.w),
2086 }
2087 }
2088}
2089
2090impl Shr<crate::IVec4> for I8Vec4 {
2091 type Output = Self;
2092 #[inline]
2093 fn shr(self, rhs: crate::IVec4) -> Self::Output {
2094 Self {
2095 x: self.x.shr(rhs.x),
2096 y: self.y.shr(rhs.y),
2097 z: self.z.shr(rhs.z),
2098 w: self.w.shr(rhs.w),
2099 }
2100 }
2101}
2102
2103impl Shl<crate::UVec4> for I8Vec4 {
2104 type Output = Self;
2105 #[inline]
2106 fn shl(self, rhs: crate::UVec4) -> Self::Output {
2107 Self {
2108 x: self.x.shl(rhs.x),
2109 y: self.y.shl(rhs.y),
2110 z: self.z.shl(rhs.z),
2111 w: self.w.shl(rhs.w),
2112 }
2113 }
2114}
2115
2116impl Shr<crate::UVec4> for I8Vec4 {
2117 type Output = Self;
2118 #[inline]
2119 fn shr(self, rhs: crate::UVec4) -> Self::Output {
2120 Self {
2121 x: self.x.shr(rhs.x),
2122 y: self.y.shr(rhs.y),
2123 z: self.z.shr(rhs.z),
2124 w: self.w.shr(rhs.w),
2125 }
2126 }
2127}
2128
2129impl Index<usize> for I8Vec4 {
2130 type Output = i8;
2131 #[inline]
2132 fn index(&self, index: usize) -> &Self::Output {
2133 match index {
2134 0 => &self.x,
2135 1 => &self.y,
2136 2 => &self.z,
2137 3 => &self.w,
2138 _ => panic!("index out of bounds"),
2139 }
2140 }
2141}
2142
2143impl IndexMut<usize> for I8Vec4 {
2144 #[inline]
2145 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
2146 match index {
2147 0 => &mut self.x,
2148 1 => &mut self.y,
2149 2 => &mut self.z,
2150 3 => &mut self.w,
2151 _ => panic!("index out of bounds"),
2152 }
2153 }
2154}
2155
2156impl fmt::Display for I8Vec4 {
2157 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2158 write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
2159 }
2160}
2161
2162impl fmt::Debug for I8Vec4 {
2163 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2164 fmt.debug_tuple(stringify!(I8Vec4))
2165 .field(&self.x)
2166 .field(&self.y)
2167 .field(&self.z)
2168 .field(&self.w)
2169 .finish()
2170 }
2171}
2172
2173impl From<[i8; 4]> for I8Vec4 {
2174 #[inline]
2175 fn from(a: [i8; 4]) -> Self {
2176 Self::new(a[0], a[1], a[2], a[3])
2177 }
2178}
2179
2180impl From<I8Vec4> for [i8; 4] {
2181 #[inline]
2182 fn from(v: I8Vec4) -> Self {
2183 [v.x, v.y, v.z, v.w]
2184 }
2185}
2186
2187impl From<(i8, i8, i8, i8)> for I8Vec4 {
2188 #[inline]
2189 fn from(t: (i8, i8, i8, i8)) -> Self {
2190 Self::new(t.0, t.1, t.2, t.3)
2191 }
2192}
2193
2194impl From<I8Vec4> for (i8, i8, i8, i8) {
2195 #[inline]
2196 fn from(v: I8Vec4) -> Self {
2197 (v.x, v.y, v.z, v.w)
2198 }
2199}
2200
2201impl From<(I8Vec3, i8)> for I8Vec4 {
2202 #[inline]
2203 fn from((v, w): (I8Vec3, i8)) -> Self {
2204 Self::new(v.x, v.y, v.z, w)
2205 }
2206}
2207
2208impl From<(i8, I8Vec3)> for I8Vec4 {
2209 #[inline]
2210 fn from((x, v): (i8, I8Vec3)) -> Self {
2211 Self::new(x, v.x, v.y, v.z)
2212 }
2213}
2214
2215impl From<(I8Vec2, i8, i8)> for I8Vec4 {
2216 #[inline]
2217 fn from((v, z, w): (I8Vec2, i8, i8)) -> Self {
2218 Self::new(v.x, v.y, z, w)
2219 }
2220}
2221
2222impl From<(I8Vec2, I8Vec2)> for I8Vec4 {
2223 #[inline]
2224 fn from((v, u): (I8Vec2, I8Vec2)) -> Self {
2225 Self::new(v.x, v.y, u.x, u.y)
2226 }
2227}
2228
2229impl TryFrom<U8Vec4> for I8Vec4 {
2230 type Error = core::num::TryFromIntError;
2231
2232 #[inline]
2233 fn try_from(v: U8Vec4) -> Result<Self, Self::Error> {
2234 Ok(Self::new(
2235 i8::try_from(v.x)?,
2236 i8::try_from(v.y)?,
2237 i8::try_from(v.z)?,
2238 i8::try_from(v.w)?,
2239 ))
2240 }
2241}
2242
2243impl TryFrom<I16Vec4> for I8Vec4 {
2244 type Error = core::num::TryFromIntError;
2245
2246 #[inline]
2247 fn try_from(v: I16Vec4) -> Result<Self, Self::Error> {
2248 Ok(Self::new(
2249 i8::try_from(v.x)?,
2250 i8::try_from(v.y)?,
2251 i8::try_from(v.z)?,
2252 i8::try_from(v.w)?,
2253 ))
2254 }
2255}
2256
2257impl TryFrom<U16Vec4> for I8Vec4 {
2258 type Error = core::num::TryFromIntError;
2259
2260 #[inline]
2261 fn try_from(v: U16Vec4) -> Result<Self, Self::Error> {
2262 Ok(Self::new(
2263 i8::try_from(v.x)?,
2264 i8::try_from(v.y)?,
2265 i8::try_from(v.z)?,
2266 i8::try_from(v.w)?,
2267 ))
2268 }
2269}
2270
2271impl TryFrom<IVec4> for I8Vec4 {
2272 type Error = core::num::TryFromIntError;
2273
2274 #[inline]
2275 fn try_from(v: IVec4) -> Result<Self, Self::Error> {
2276 Ok(Self::new(
2277 i8::try_from(v.x)?,
2278 i8::try_from(v.y)?,
2279 i8::try_from(v.z)?,
2280 i8::try_from(v.w)?,
2281 ))
2282 }
2283}
2284
2285impl TryFrom<UVec4> for I8Vec4 {
2286 type Error = core::num::TryFromIntError;
2287
2288 #[inline]
2289 fn try_from(v: UVec4) -> Result<Self, Self::Error> {
2290 Ok(Self::new(
2291 i8::try_from(v.x)?,
2292 i8::try_from(v.y)?,
2293 i8::try_from(v.z)?,
2294 i8::try_from(v.w)?,
2295 ))
2296 }
2297}
2298
2299impl TryFrom<I64Vec4> for I8Vec4 {
2300 type Error = core::num::TryFromIntError;
2301
2302 #[inline]
2303 fn try_from(v: I64Vec4) -> Result<Self, Self::Error> {
2304 Ok(Self::new(
2305 i8::try_from(v.x)?,
2306 i8::try_from(v.y)?,
2307 i8::try_from(v.z)?,
2308 i8::try_from(v.w)?,
2309 ))
2310 }
2311}
2312
2313impl TryFrom<U64Vec4> for I8Vec4 {
2314 type Error = core::num::TryFromIntError;
2315
2316 #[inline]
2317 fn try_from(v: U64Vec4) -> Result<Self, Self::Error> {
2318 Ok(Self::new(
2319 i8::try_from(v.x)?,
2320 i8::try_from(v.y)?,
2321 i8::try_from(v.z)?,
2322 i8::try_from(v.w)?,
2323 ))
2324 }
2325}
2326
2327impl TryFrom<USizeVec4> for I8Vec4 {
2328 type Error = core::num::TryFromIntError;
2329
2330 #[inline]
2331 fn try_from(v: USizeVec4) -> Result<Self, Self::Error> {
2332 Ok(Self::new(
2333 i8::try_from(v.x)?,
2334 i8::try_from(v.y)?,
2335 i8::try_from(v.z)?,
2336 i8::try_from(v.w)?,
2337 ))
2338 }
2339}
2340
2341impl From<BVec4> for I8Vec4 {
2342 #[inline]
2343 fn from(v: BVec4) -> Self {
2344 Self::new(i8::from(v.x), i8::from(v.y), i8::from(v.z), i8::from(v.w))
2345 }
2346}
2347
2348#[cfg(not(feature = "scalar-math"))]
2349impl From<BVec4A> for I8Vec4 {
2350 #[inline]
2351 fn from(v: BVec4A) -> Self {
2352 let bool_array: [bool; 4] = v.into();
2353 Self::new(
2354 i8::from(bool_array[0]),
2355 i8::from(bool_array[1]),
2356 i8::from(bool_array[2]),
2357 i8::from(bool_array[3]),
2358 )
2359 }
2360}