1#[cfg(not(feature = "scalar-math"))]
4use crate::BVec4A;
5use crate::{BVec4, I8Vec2, I8Vec3};
6
7#[cfg(feature = "u8")]
8use crate::U8Vec4;
9
10#[cfg(feature = "i16")]
11use crate::I16Vec4;
12
13#[cfg(feature = "u16")]
14use crate::U16Vec4;
15
16#[cfg(feature = "i32")]
17use crate::IVec4;
18
19#[cfg(feature = "u32")]
20use crate::UVec4;
21
22#[cfg(feature = "i64")]
23use crate::I64Vec4;
24
25#[cfg(feature = "u64")]
26use crate::U64Vec4;
27
28#[cfg(feature = "isize")]
29use crate::ISizeVec4;
30
31#[cfg(feature = "usize")]
32use crate::USizeVec4;
33
34use core::fmt;
35use core::iter::{Product, Sum};
36use core::{f32, ops::*};
37
38#[cfg(feature = "zerocopy")]
39use zerocopy_derive::*;
40
41#[inline(always)]
43#[must_use]
44pub const fn i8vec4(x: i8, y: i8, z: i8, w: i8) -> I8Vec4 {
45 I8Vec4::new(x, y, z, w)
46}
47
48#[derive(Clone, Copy, PartialEq, Eq, Hash)]
50#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
51#[cfg_attr(
52 feature = "zerocopy",
53 derive(FromBytes, Immutable, IntoBytes, KnownLayout)
54)]
55#[cfg_attr(feature = "cuda", repr(align(4)))]
56#[repr(C)]
57#[cfg_attr(target_arch = "spirv", rust_gpu::vector::v1)]
58pub struct I8Vec4 {
59 pub x: i8,
60 pub y: i8,
61 pub z: i8,
62 pub w: i8,
63}
64
65impl I8Vec4 {
66 pub const ZERO: Self = Self::splat(0);
68
69 pub const ONE: Self = Self::splat(1);
71
72 pub const NEG_ONE: Self = Self::splat(-1);
74
75 pub const MIN: Self = Self::splat(i8::MIN);
77
78 pub const MAX: Self = Self::splat(i8::MAX);
80
81 pub const X: Self = Self::new(1, 0, 0, 0);
83
84 pub const Y: Self = Self::new(0, 1, 0, 0);
86
87 pub const Z: Self = Self::new(0, 0, 1, 0);
89
90 pub const W: Self = Self::new(0, 0, 0, 1);
92
93 pub const NEG_X: Self = Self::new(-1, 0, 0, 0);
95
96 pub const NEG_Y: Self = Self::new(0, -1, 0, 0);
98
99 pub const NEG_Z: Self = Self::new(0, 0, -1, 0);
101
102 pub const NEG_W: Self = Self::new(0, 0, 0, -1);
104
105 pub const AXES: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
107
108 #[inline(always)]
110 #[must_use]
111 pub const fn new(x: i8, y: i8, z: i8, w: i8) -> Self {
112 Self { x, y, z, w }
113 }
114
115 #[inline]
117 #[must_use]
118 pub const fn splat(v: i8) -> Self {
119 Self {
120 x: v,
121
122 y: v,
123
124 z: v,
125
126 w: v,
127 }
128 }
129
130 #[inline]
132 #[must_use]
133 pub fn map<F>(self, mut f: F) -> Self
134 where
135 F: FnMut(i8) -> i8,
136 {
137 Self::new(f(self.x), f(self.y), f(self.z), f(self.w))
138 }
139
140 #[inline]
146 #[must_use]
147 pub fn select(mask: BVec4, if_true: Self, if_false: Self) -> Self {
148 Self {
149 x: if mask.test(0) { if_true.x } else { if_false.x },
150 y: if mask.test(1) { if_true.y } else { if_false.y },
151 z: if mask.test(2) { if_true.z } else { if_false.z },
152 w: if mask.test(3) { if_true.w } else { if_false.w },
153 }
154 }
155
156 #[inline]
158 #[must_use]
159 pub const fn from_array(a: [i8; 4]) -> Self {
160 Self::new(a[0], a[1], a[2], a[3])
161 }
162
163 #[inline]
165 #[must_use]
166 pub const fn to_array(&self) -> [i8; 4] {
167 [self.x, self.y, self.z, self.w]
168 }
169
170 #[inline]
176 #[must_use]
177 pub const fn from_slice(slice: &[i8]) -> Self {
178 assert!(slice.len() >= 4);
179 Self::new(slice[0], slice[1], slice[2], slice[3])
180 }
181
182 #[inline]
188 pub fn write_to_slice(self, slice: &mut [i8]) {
189 slice[..4].copy_from_slice(&self.to_array());
190 }
191
192 #[inline]
196 #[must_use]
197 pub fn truncate(self) -> I8Vec3 {
198 use crate::swizzles::Vec4Swizzles;
199 self.xyz()
200 }
201
202 #[inline]
204 #[must_use]
205 pub fn with_x(mut self, x: i8) -> Self {
206 self.x = x;
207 self
208 }
209
210 #[inline]
212 #[must_use]
213 pub fn with_y(mut self, y: i8) -> Self {
214 self.y = y;
215 self
216 }
217
218 #[inline]
220 #[must_use]
221 pub fn with_z(mut self, z: i8) -> Self {
222 self.z = z;
223 self
224 }
225
226 #[inline]
228 #[must_use]
229 pub fn with_w(mut self, w: i8) -> Self {
230 self.w = w;
231 self
232 }
233
234 #[inline]
236 #[must_use]
237 pub fn dot(self, rhs: Self) -> i8 {
238 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) + (self.w * rhs.w)
239 }
240
241 #[inline]
243 #[must_use]
244 pub fn dot_into_vec(self, rhs: Self) -> Self {
245 Self::splat(self.dot(rhs))
246 }
247
248 #[inline]
252 #[must_use]
253 pub fn min(self, rhs: Self) -> Self {
254 Self {
255 x: if self.x < rhs.x { self.x } else { rhs.x },
256 y: if self.y < rhs.y { self.y } else { rhs.y },
257 z: if self.z < rhs.z { self.z } else { rhs.z },
258 w: if self.w < rhs.w { self.w } else { rhs.w },
259 }
260 }
261
262 #[inline]
266 #[must_use]
267 pub fn max(self, rhs: Self) -> Self {
268 Self {
269 x: if self.x > rhs.x { self.x } else { rhs.x },
270 y: if self.y > rhs.y { self.y } else { rhs.y },
271 z: if self.z > rhs.z { self.z } else { rhs.z },
272 w: if self.w > rhs.w { self.w } else { rhs.w },
273 }
274 }
275
276 #[inline]
284 #[must_use]
285 pub fn clamp(self, min: Self, max: Self) -> Self {
286 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
287 self.max(min).min(max)
288 }
289
290 #[inline]
294 #[must_use]
295 pub fn min_element(self) -> i8 {
296 let min = |a, b| if a < b { a } else { b };
297 min(self.x, min(self.y, min(self.z, self.w)))
298 }
299
300 #[inline]
304 #[must_use]
305 pub fn max_element(self) -> i8 {
306 let max = |a, b| if a > b { a } else { b };
307 max(self.x, max(self.y, max(self.z, self.w)))
308 }
309
310 #[doc(alias = "argmin")]
312 #[inline]
313 #[must_use]
314 pub fn min_position(self) -> usize {
315 let mut min = self.x;
316 let mut index = 0;
317 if self.y < min {
318 min = self.y;
319 index = 1;
320 }
321 if self.z < min {
322 min = self.z;
323 index = 2;
324 }
325 if self.w < min {
326 index = 3;
327 }
328 index
329 }
330
331 #[doc(alias = "argmax")]
333 #[inline]
334 #[must_use]
335 pub fn max_position(self) -> usize {
336 let mut max = self.x;
337 let mut index = 0;
338 if self.y > max {
339 max = self.y;
340 index = 1;
341 }
342 if self.z > max {
343 max = self.z;
344 index = 2;
345 }
346 if self.w > max {
347 index = 3;
348 }
349 index
350 }
351
352 #[inline]
356 #[must_use]
357 pub fn element_sum(self) -> i8 {
358 self.x + self.y + self.z + self.w
359 }
360
361 #[inline]
365 #[must_use]
366 pub fn element_product(self) -> i8 {
367 self.x * self.y * self.z * self.w
368 }
369
370 #[inline]
376 #[must_use]
377 pub fn cmpeq(self, rhs: Self) -> BVec4 {
378 BVec4::new(
379 self.x.eq(&rhs.x),
380 self.y.eq(&rhs.y),
381 self.z.eq(&rhs.z),
382 self.w.eq(&rhs.w),
383 )
384 }
385
386 #[inline]
392 #[must_use]
393 pub fn cmpne(self, rhs: Self) -> BVec4 {
394 BVec4::new(
395 self.x.ne(&rhs.x),
396 self.y.ne(&rhs.y),
397 self.z.ne(&rhs.z),
398 self.w.ne(&rhs.w),
399 )
400 }
401
402 #[inline]
408 #[must_use]
409 pub fn cmpge(self, rhs: Self) -> BVec4 {
410 BVec4::new(
411 self.x.ge(&rhs.x),
412 self.y.ge(&rhs.y),
413 self.z.ge(&rhs.z),
414 self.w.ge(&rhs.w),
415 )
416 }
417
418 #[inline]
424 #[must_use]
425 pub fn cmpgt(self, rhs: Self) -> BVec4 {
426 BVec4::new(
427 self.x.gt(&rhs.x),
428 self.y.gt(&rhs.y),
429 self.z.gt(&rhs.z),
430 self.w.gt(&rhs.w),
431 )
432 }
433
434 #[inline]
440 #[must_use]
441 pub fn cmple(self, rhs: Self) -> BVec4 {
442 BVec4::new(
443 self.x.le(&rhs.x),
444 self.y.le(&rhs.y),
445 self.z.le(&rhs.z),
446 self.w.le(&rhs.w),
447 )
448 }
449
450 #[inline]
456 #[must_use]
457 pub fn cmplt(self, rhs: Self) -> BVec4 {
458 BVec4::new(
459 self.x.lt(&rhs.x),
460 self.y.lt(&rhs.y),
461 self.z.lt(&rhs.z),
462 self.w.lt(&rhs.w),
463 )
464 }
465
466 #[inline]
468 #[must_use]
469 pub fn abs(self) -> Self {
470 Self {
471 x: self.x.abs(),
472 y: self.y.abs(),
473 z: self.z.abs(),
474 w: self.w.abs(),
475 }
476 }
477
478 #[inline]
484 #[must_use]
485 pub fn signum(self) -> Self {
486 Self {
487 x: self.x.signum(),
488 y: self.y.signum(),
489 z: self.z.signum(),
490 w: self.w.signum(),
491 }
492 }
493
494 #[inline]
502 #[must_use]
503 pub fn is_negative_bitmask(self) -> u32 {
504 (self.x.is_negative() as u32)
505 | ((self.y.is_negative() as u32) << 1)
506 | ((self.z.is_negative() as u32) << 2)
507 | ((self.w.is_negative() as u32) << 3)
508 }
509
510 #[inline]
515 #[must_use]
516 pub fn is_negative_mask(self) -> BVec4 {
517 BVec4::new(
518 self.x.is_negative(),
519 self.y.is_negative(),
520 self.z.is_negative(),
521 self.w.is_negative(),
522 )
523 }
524
525 #[doc(alias = "magnitude2")]
527 #[inline]
528 #[must_use]
529 pub fn length_squared(self) -> i8 {
530 self.dot(self)
531 }
532
533 #[inline]
535 #[must_use]
536 pub fn distance_squared(self, rhs: Self) -> i8 {
537 (self - rhs).length_squared()
538 }
539
540 #[inline]
545 #[must_use]
546 pub fn div_euclid(self, rhs: Self) -> Self {
547 Self::new(
548 self.x.div_euclid(rhs.x),
549 self.y.div_euclid(rhs.y),
550 self.z.div_euclid(rhs.z),
551 self.w.div_euclid(rhs.w),
552 )
553 }
554
555 #[inline]
562 #[must_use]
563 pub fn rem_euclid(self, rhs: Self) -> Self {
564 Self::new(
565 self.x.rem_euclid(rhs.x),
566 self.y.rem_euclid(rhs.y),
567 self.z.rem_euclid(rhs.z),
568 self.w.rem_euclid(rhs.w),
569 )
570 }
571
572 #[inline]
581 #[must_use]
582 pub fn manhattan_distance(self, rhs: Self) -> u8 {
583 self.x.abs_diff(rhs.x)
584 + self.y.abs_diff(rhs.y)
585 + self.z.abs_diff(rhs.z)
586 + self.w.abs_diff(rhs.w)
587 }
588
589 #[inline]
595 #[must_use]
596 pub fn checked_manhattan_distance(self, rhs: Self) -> Option<u8> {
597 let d = self.x.abs_diff(rhs.x);
598 let d = d.checked_add(self.y.abs_diff(rhs.y))?;
599 let d = d.checked_add(self.z.abs_diff(rhs.z))?;
600 d.checked_add(self.w.abs_diff(rhs.w))
601 }
602
603 #[inline]
607 #[must_use]
608 pub fn chebyshev_distance(self, rhs: Self) -> u8 {
609 [
611 self.x.abs_diff(rhs.x),
612 self.y.abs_diff(rhs.y),
613 self.z.abs_diff(rhs.z),
614 self.w.abs_diff(rhs.w),
615 ]
616 .into_iter()
617 .max()
618 .unwrap()
619 }
620
621 #[inline]
623 #[must_use]
624 pub fn as_vec4(self) -> crate::Vec4 {
625 crate::Vec4::new(self.x as f32, self.y as f32, self.z as f32, self.w as f32)
626 }
627
628 #[cfg(feature = "f64")]
630 #[inline]
631 #[must_use]
632 pub fn as_dvec4(self) -> crate::DVec4 {
633 crate::DVec4::new(self.x as f64, self.y as f64, self.z as f64, self.w as f64)
634 }
635
636 #[cfg(feature = "u8")]
638 #[inline]
639 #[must_use]
640 pub fn as_u8vec4(self) -> crate::U8Vec4 {
641 crate::U8Vec4::new(self.x as u8, self.y as u8, self.z as u8, self.w as u8)
642 }
643
644 #[cfg(feature = "i16")]
646 #[inline]
647 #[must_use]
648 pub fn as_i16vec4(self) -> crate::I16Vec4 {
649 crate::I16Vec4::new(self.x as i16, self.y as i16, self.z as i16, self.w as i16)
650 }
651
652 #[cfg(feature = "u16")]
654 #[inline]
655 #[must_use]
656 pub fn as_u16vec4(self) -> crate::U16Vec4 {
657 crate::U16Vec4::new(self.x as u16, self.y as u16, self.z as u16, self.w as u16)
658 }
659
660 #[cfg(feature = "i32")]
662 #[inline]
663 #[must_use]
664 pub fn as_ivec4(self) -> crate::IVec4 {
665 crate::IVec4::new(self.x as i32, self.y as i32, self.z as i32, self.w as i32)
666 }
667
668 #[cfg(feature = "u32")]
670 #[inline]
671 #[must_use]
672 pub fn as_uvec4(self) -> crate::UVec4 {
673 crate::UVec4::new(self.x as u32, self.y as u32, self.z as u32, self.w as u32)
674 }
675
676 #[cfg(feature = "i64")]
678 #[inline]
679 #[must_use]
680 pub fn as_i64vec4(self) -> crate::I64Vec4 {
681 crate::I64Vec4::new(self.x as i64, self.y as i64, self.z as i64, self.w as i64)
682 }
683
684 #[cfg(feature = "u64")]
686 #[inline]
687 #[must_use]
688 pub fn as_u64vec4(self) -> crate::U64Vec4 {
689 crate::U64Vec4::new(self.x as u64, self.y as u64, self.z as u64, self.w as u64)
690 }
691
692 #[cfg(feature = "isize")]
694 #[inline]
695 #[must_use]
696 pub fn as_isizevec4(self) -> crate::ISizeVec4 {
697 crate::ISizeVec4::new(
698 self.x as isize,
699 self.y as isize,
700 self.z as isize,
701 self.w as isize,
702 )
703 }
704
705 #[cfg(feature = "usize")]
707 #[inline]
708 #[must_use]
709 pub fn as_usizevec4(self) -> crate::USizeVec4 {
710 crate::USizeVec4::new(
711 self.x as usize,
712 self.y as usize,
713 self.z as usize,
714 self.w as usize,
715 )
716 }
717
718 #[inline]
722 #[must_use]
723 pub const fn checked_add(self, rhs: Self) -> Option<Self> {
724 let x = match self.x.checked_add(rhs.x) {
725 Some(v) => v,
726 None => return None,
727 };
728 let y = match self.y.checked_add(rhs.y) {
729 Some(v) => v,
730 None => return None,
731 };
732 let z = match self.z.checked_add(rhs.z) {
733 Some(v) => v,
734 None => return None,
735 };
736 let w = match self.w.checked_add(rhs.w) {
737 Some(v) => v,
738 None => return None,
739 };
740
741 Some(Self { x, y, z, w })
742 }
743
744 #[inline]
748 #[must_use]
749 pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
750 let x = match self.x.checked_sub(rhs.x) {
751 Some(v) => v,
752 None => return None,
753 };
754 let y = match self.y.checked_sub(rhs.y) {
755 Some(v) => v,
756 None => return None,
757 };
758 let z = match self.z.checked_sub(rhs.z) {
759 Some(v) => v,
760 None => return None,
761 };
762 let w = match self.w.checked_sub(rhs.w) {
763 Some(v) => v,
764 None => return None,
765 };
766
767 Some(Self { x, y, z, w })
768 }
769
770 #[inline]
774 #[must_use]
775 pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
776 let x = match self.x.checked_mul(rhs.x) {
777 Some(v) => v,
778 None => return None,
779 };
780 let y = match self.y.checked_mul(rhs.y) {
781 Some(v) => v,
782 None => return None,
783 };
784 let z = match self.z.checked_mul(rhs.z) {
785 Some(v) => v,
786 None => return None,
787 };
788 let w = match self.w.checked_mul(rhs.w) {
789 Some(v) => v,
790 None => return None,
791 };
792
793 Some(Self { x, y, z, w })
794 }
795
796 #[inline]
800 #[must_use]
801 pub const fn checked_div(self, rhs: Self) -> Option<Self> {
802 let x = match self.x.checked_div(rhs.x) {
803 Some(v) => v,
804 None => return None,
805 };
806 let y = match self.y.checked_div(rhs.y) {
807 Some(v) => v,
808 None => return None,
809 };
810 let z = match self.z.checked_div(rhs.z) {
811 Some(v) => v,
812 None => return None,
813 };
814 let w = match self.w.checked_div(rhs.w) {
815 Some(v) => v,
816 None => return None,
817 };
818
819 Some(Self { x, y, z, w })
820 }
821
822 #[inline]
826 #[must_use]
827 pub const fn wrapping_add(self, rhs: Self) -> Self {
828 Self {
829 x: self.x.wrapping_add(rhs.x),
830 y: self.y.wrapping_add(rhs.y),
831 z: self.z.wrapping_add(rhs.z),
832 w: self.w.wrapping_add(rhs.w),
833 }
834 }
835
836 #[inline]
840 #[must_use]
841 pub const fn wrapping_sub(self, rhs: Self) -> Self {
842 Self {
843 x: self.x.wrapping_sub(rhs.x),
844 y: self.y.wrapping_sub(rhs.y),
845 z: self.z.wrapping_sub(rhs.z),
846 w: self.w.wrapping_sub(rhs.w),
847 }
848 }
849
850 #[inline]
854 #[must_use]
855 pub const fn wrapping_mul(self, rhs: Self) -> Self {
856 Self {
857 x: self.x.wrapping_mul(rhs.x),
858 y: self.y.wrapping_mul(rhs.y),
859 z: self.z.wrapping_mul(rhs.z),
860 w: self.w.wrapping_mul(rhs.w),
861 }
862 }
863
864 #[inline]
868 #[must_use]
869 pub const fn wrapping_div(self, rhs: Self) -> Self {
870 Self {
871 x: self.x.wrapping_div(rhs.x),
872 y: self.y.wrapping_div(rhs.y),
873 z: self.z.wrapping_div(rhs.z),
874 w: self.w.wrapping_div(rhs.w),
875 }
876 }
877
878 #[inline]
882 #[must_use]
883 pub const fn saturating_add(self, rhs: Self) -> Self {
884 Self {
885 x: self.x.saturating_add(rhs.x),
886 y: self.y.saturating_add(rhs.y),
887 z: self.z.saturating_add(rhs.z),
888 w: self.w.saturating_add(rhs.w),
889 }
890 }
891
892 #[inline]
896 #[must_use]
897 pub const fn saturating_sub(self, rhs: Self) -> Self {
898 Self {
899 x: self.x.saturating_sub(rhs.x),
900 y: self.y.saturating_sub(rhs.y),
901 z: self.z.saturating_sub(rhs.z),
902 w: self.w.saturating_sub(rhs.w),
903 }
904 }
905
906 #[inline]
910 #[must_use]
911 pub const fn saturating_mul(self, rhs: Self) -> Self {
912 Self {
913 x: self.x.saturating_mul(rhs.x),
914 y: self.y.saturating_mul(rhs.y),
915 z: self.z.saturating_mul(rhs.z),
916 w: self.w.saturating_mul(rhs.w),
917 }
918 }
919
920 #[inline]
924 #[must_use]
925 pub const fn saturating_div(self, rhs: Self) -> Self {
926 Self {
927 x: self.x.saturating_div(rhs.x),
928 y: self.y.saturating_div(rhs.y),
929 z: self.z.saturating_div(rhs.z),
930 w: self.w.saturating_div(rhs.w),
931 }
932 }
933
934 #[cfg(feature = "u8")]
938 #[inline]
939 #[must_use]
940 pub const fn checked_add_unsigned(self, rhs: U8Vec4) -> Option<Self> {
941 let x = match self.x.checked_add_unsigned(rhs.x) {
942 Some(v) => v,
943 None => return None,
944 };
945 let y = match self.y.checked_add_unsigned(rhs.y) {
946 Some(v) => v,
947 None => return None,
948 };
949 let z = match self.z.checked_add_unsigned(rhs.z) {
950 Some(v) => v,
951 None => return None,
952 };
953 let w = match self.w.checked_add_unsigned(rhs.w) {
954 Some(v) => v,
955 None => return None,
956 };
957
958 Some(Self { x, y, z, w })
959 }
960
961 #[cfg(feature = "u8")]
965 #[inline]
966 #[must_use]
967 pub const fn checked_sub_unsigned(self, rhs: U8Vec4) -> Option<Self> {
968 let x = match self.x.checked_sub_unsigned(rhs.x) {
969 Some(v) => v,
970 None => return None,
971 };
972 let y = match self.y.checked_sub_unsigned(rhs.y) {
973 Some(v) => v,
974 None => return None,
975 };
976 let z = match self.z.checked_sub_unsigned(rhs.z) {
977 Some(v) => v,
978 None => return None,
979 };
980 let w = match self.w.checked_sub_unsigned(rhs.w) {
981 Some(v) => v,
982 None => return None,
983 };
984
985 Some(Self { x, y, z, w })
986 }
987
988 #[cfg(feature = "u8")]
992 #[inline]
993 #[must_use]
994 pub const fn wrapping_add_unsigned(self, rhs: U8Vec4) -> Self {
995 Self {
996 x: self.x.wrapping_add_unsigned(rhs.x),
997 y: self.y.wrapping_add_unsigned(rhs.y),
998 z: self.z.wrapping_add_unsigned(rhs.z),
999 w: self.w.wrapping_add_unsigned(rhs.w),
1000 }
1001 }
1002
1003 #[cfg(feature = "u8")]
1007 #[inline]
1008 #[must_use]
1009 pub const fn wrapping_sub_unsigned(self, rhs: U8Vec4) -> Self {
1010 Self {
1011 x: self.x.wrapping_sub_unsigned(rhs.x),
1012 y: self.y.wrapping_sub_unsigned(rhs.y),
1013 z: self.z.wrapping_sub_unsigned(rhs.z),
1014 w: self.w.wrapping_sub_unsigned(rhs.w),
1015 }
1016 }
1017
1018 #[cfg(feature = "u8")]
1022 #[inline]
1023 #[must_use]
1024 pub const fn saturating_add_unsigned(self, rhs: U8Vec4) -> Self {
1025 Self {
1026 x: self.x.saturating_add_unsigned(rhs.x),
1027 y: self.y.saturating_add_unsigned(rhs.y),
1028 z: self.z.saturating_add_unsigned(rhs.z),
1029 w: self.w.saturating_add_unsigned(rhs.w),
1030 }
1031 }
1032
1033 #[cfg(feature = "u8")]
1037 #[inline]
1038 #[must_use]
1039 pub const fn saturating_sub_unsigned(self, rhs: U8Vec4) -> Self {
1040 Self {
1041 x: self.x.saturating_sub_unsigned(rhs.x),
1042 y: self.y.saturating_sub_unsigned(rhs.y),
1043 z: self.z.saturating_sub_unsigned(rhs.z),
1044 w: self.w.saturating_sub_unsigned(rhs.w),
1045 }
1046 }
1047}
1048
1049impl Default for I8Vec4 {
1050 #[inline(always)]
1051 fn default() -> Self {
1052 Self::ZERO
1053 }
1054}
1055
1056impl Div for I8Vec4 {
1057 type Output = Self;
1058 #[inline]
1059 fn div(self, rhs: Self) -> Self {
1060 Self {
1061 x: self.x.div(rhs.x),
1062 y: self.y.div(rhs.y),
1063 z: self.z.div(rhs.z),
1064 w: self.w.div(rhs.w),
1065 }
1066 }
1067}
1068
1069impl Div<&Self> for I8Vec4 {
1070 type Output = Self;
1071 #[inline]
1072 fn div(self, rhs: &Self) -> Self {
1073 self.div(*rhs)
1074 }
1075}
1076
1077impl Div<&I8Vec4> for &I8Vec4 {
1078 type Output = I8Vec4;
1079 #[inline]
1080 fn div(self, rhs: &I8Vec4) -> I8Vec4 {
1081 (*self).div(*rhs)
1082 }
1083}
1084
1085impl Div<I8Vec4> for &I8Vec4 {
1086 type Output = I8Vec4;
1087 #[inline]
1088 fn div(self, rhs: I8Vec4) -> I8Vec4 {
1089 (*self).div(rhs)
1090 }
1091}
1092
1093impl DivAssign for I8Vec4 {
1094 #[inline]
1095 fn div_assign(&mut self, rhs: Self) {
1096 self.x.div_assign(rhs.x);
1097 self.y.div_assign(rhs.y);
1098 self.z.div_assign(rhs.z);
1099 self.w.div_assign(rhs.w);
1100 }
1101}
1102
1103impl DivAssign<&Self> for I8Vec4 {
1104 #[inline]
1105 fn div_assign(&mut self, rhs: &Self) {
1106 self.div_assign(*rhs);
1107 }
1108}
1109
1110impl Div<i8> for I8Vec4 {
1111 type Output = Self;
1112 #[inline]
1113 fn div(self, rhs: i8) -> Self {
1114 Self {
1115 x: self.x.div(rhs),
1116 y: self.y.div(rhs),
1117 z: self.z.div(rhs),
1118 w: self.w.div(rhs),
1119 }
1120 }
1121}
1122
1123impl Div<&i8> for I8Vec4 {
1124 type Output = Self;
1125 #[inline]
1126 fn div(self, rhs: &i8) -> Self {
1127 self.div(*rhs)
1128 }
1129}
1130
1131impl Div<&i8> for &I8Vec4 {
1132 type Output = I8Vec4;
1133 #[inline]
1134 fn div(self, rhs: &i8) -> I8Vec4 {
1135 (*self).div(*rhs)
1136 }
1137}
1138
1139impl Div<i8> for &I8Vec4 {
1140 type Output = I8Vec4;
1141 #[inline]
1142 fn div(self, rhs: i8) -> I8Vec4 {
1143 (*self).div(rhs)
1144 }
1145}
1146
1147impl DivAssign<i8> for I8Vec4 {
1148 #[inline]
1149 fn div_assign(&mut self, rhs: i8) {
1150 self.x.div_assign(rhs);
1151 self.y.div_assign(rhs);
1152 self.z.div_assign(rhs);
1153 self.w.div_assign(rhs);
1154 }
1155}
1156
1157impl DivAssign<&i8> for I8Vec4 {
1158 #[inline]
1159 fn div_assign(&mut self, rhs: &i8) {
1160 self.div_assign(*rhs);
1161 }
1162}
1163
1164impl Div<I8Vec4> for i8 {
1165 type Output = I8Vec4;
1166 #[inline]
1167 fn div(self, rhs: I8Vec4) -> I8Vec4 {
1168 I8Vec4 {
1169 x: self.div(rhs.x),
1170 y: self.div(rhs.y),
1171 z: self.div(rhs.z),
1172 w: self.div(rhs.w),
1173 }
1174 }
1175}
1176
1177impl Div<&I8Vec4> for i8 {
1178 type Output = I8Vec4;
1179 #[inline]
1180 fn div(self, rhs: &I8Vec4) -> I8Vec4 {
1181 self.div(*rhs)
1182 }
1183}
1184
1185impl Div<&I8Vec4> for &i8 {
1186 type Output = I8Vec4;
1187 #[inline]
1188 fn div(self, rhs: &I8Vec4) -> I8Vec4 {
1189 (*self).div(*rhs)
1190 }
1191}
1192
1193impl Div<I8Vec4> for &i8 {
1194 type Output = I8Vec4;
1195 #[inline]
1196 fn div(self, rhs: I8Vec4) -> I8Vec4 {
1197 (*self).div(rhs)
1198 }
1199}
1200
1201impl Mul for I8Vec4 {
1202 type Output = Self;
1203 #[inline]
1204 fn mul(self, rhs: Self) -> Self {
1205 Self {
1206 x: self.x.mul(rhs.x),
1207 y: self.y.mul(rhs.y),
1208 z: self.z.mul(rhs.z),
1209 w: self.w.mul(rhs.w),
1210 }
1211 }
1212}
1213
1214impl Mul<&Self> for I8Vec4 {
1215 type Output = Self;
1216 #[inline]
1217 fn mul(self, rhs: &Self) -> Self {
1218 self.mul(*rhs)
1219 }
1220}
1221
1222impl Mul<&I8Vec4> for &I8Vec4 {
1223 type Output = I8Vec4;
1224 #[inline]
1225 fn mul(self, rhs: &I8Vec4) -> I8Vec4 {
1226 (*self).mul(*rhs)
1227 }
1228}
1229
1230impl Mul<I8Vec4> for &I8Vec4 {
1231 type Output = I8Vec4;
1232 #[inline]
1233 fn mul(self, rhs: I8Vec4) -> I8Vec4 {
1234 (*self).mul(rhs)
1235 }
1236}
1237
1238impl MulAssign for I8Vec4 {
1239 #[inline]
1240 fn mul_assign(&mut self, rhs: Self) {
1241 self.x.mul_assign(rhs.x);
1242 self.y.mul_assign(rhs.y);
1243 self.z.mul_assign(rhs.z);
1244 self.w.mul_assign(rhs.w);
1245 }
1246}
1247
1248impl MulAssign<&Self> for I8Vec4 {
1249 #[inline]
1250 fn mul_assign(&mut self, rhs: &Self) {
1251 self.mul_assign(*rhs);
1252 }
1253}
1254
1255impl Mul<i8> for I8Vec4 {
1256 type Output = Self;
1257 #[inline]
1258 fn mul(self, rhs: i8) -> Self {
1259 Self {
1260 x: self.x.mul(rhs),
1261 y: self.y.mul(rhs),
1262 z: self.z.mul(rhs),
1263 w: self.w.mul(rhs),
1264 }
1265 }
1266}
1267
1268impl Mul<&i8> for I8Vec4 {
1269 type Output = Self;
1270 #[inline]
1271 fn mul(self, rhs: &i8) -> Self {
1272 self.mul(*rhs)
1273 }
1274}
1275
1276impl Mul<&i8> for &I8Vec4 {
1277 type Output = I8Vec4;
1278 #[inline]
1279 fn mul(self, rhs: &i8) -> I8Vec4 {
1280 (*self).mul(*rhs)
1281 }
1282}
1283
1284impl Mul<i8> for &I8Vec4 {
1285 type Output = I8Vec4;
1286 #[inline]
1287 fn mul(self, rhs: i8) -> I8Vec4 {
1288 (*self).mul(rhs)
1289 }
1290}
1291
1292impl MulAssign<i8> for I8Vec4 {
1293 #[inline]
1294 fn mul_assign(&mut self, rhs: i8) {
1295 self.x.mul_assign(rhs);
1296 self.y.mul_assign(rhs);
1297 self.z.mul_assign(rhs);
1298 self.w.mul_assign(rhs);
1299 }
1300}
1301
1302impl MulAssign<&i8> for I8Vec4 {
1303 #[inline]
1304 fn mul_assign(&mut self, rhs: &i8) {
1305 self.mul_assign(*rhs);
1306 }
1307}
1308
1309impl Mul<I8Vec4> for i8 {
1310 type Output = I8Vec4;
1311 #[inline]
1312 fn mul(self, rhs: I8Vec4) -> I8Vec4 {
1313 I8Vec4 {
1314 x: self.mul(rhs.x),
1315 y: self.mul(rhs.y),
1316 z: self.mul(rhs.z),
1317 w: self.mul(rhs.w),
1318 }
1319 }
1320}
1321
1322impl Mul<&I8Vec4> for i8 {
1323 type Output = I8Vec4;
1324 #[inline]
1325 fn mul(self, rhs: &I8Vec4) -> I8Vec4 {
1326 self.mul(*rhs)
1327 }
1328}
1329
1330impl Mul<&I8Vec4> for &i8 {
1331 type Output = I8Vec4;
1332 #[inline]
1333 fn mul(self, rhs: &I8Vec4) -> I8Vec4 {
1334 (*self).mul(*rhs)
1335 }
1336}
1337
1338impl Mul<I8Vec4> for &i8 {
1339 type Output = I8Vec4;
1340 #[inline]
1341 fn mul(self, rhs: I8Vec4) -> I8Vec4 {
1342 (*self).mul(rhs)
1343 }
1344}
1345
1346impl Add for I8Vec4 {
1347 type Output = Self;
1348 #[inline]
1349 fn add(self, rhs: Self) -> Self {
1350 Self {
1351 x: self.x.add(rhs.x),
1352 y: self.y.add(rhs.y),
1353 z: self.z.add(rhs.z),
1354 w: self.w.add(rhs.w),
1355 }
1356 }
1357}
1358
1359impl Add<&Self> for I8Vec4 {
1360 type Output = Self;
1361 #[inline]
1362 fn add(self, rhs: &Self) -> Self {
1363 self.add(*rhs)
1364 }
1365}
1366
1367impl Add<&I8Vec4> for &I8Vec4 {
1368 type Output = I8Vec4;
1369 #[inline]
1370 fn add(self, rhs: &I8Vec4) -> I8Vec4 {
1371 (*self).add(*rhs)
1372 }
1373}
1374
1375impl Add<I8Vec4> for &I8Vec4 {
1376 type Output = I8Vec4;
1377 #[inline]
1378 fn add(self, rhs: I8Vec4) -> I8Vec4 {
1379 (*self).add(rhs)
1380 }
1381}
1382
1383impl AddAssign for I8Vec4 {
1384 #[inline]
1385 fn add_assign(&mut self, rhs: Self) {
1386 self.x.add_assign(rhs.x);
1387 self.y.add_assign(rhs.y);
1388 self.z.add_assign(rhs.z);
1389 self.w.add_assign(rhs.w);
1390 }
1391}
1392
1393impl AddAssign<&Self> for I8Vec4 {
1394 #[inline]
1395 fn add_assign(&mut self, rhs: &Self) {
1396 self.add_assign(*rhs);
1397 }
1398}
1399
1400impl Add<i8> for I8Vec4 {
1401 type Output = Self;
1402 #[inline]
1403 fn add(self, rhs: i8) -> Self {
1404 Self {
1405 x: self.x.add(rhs),
1406 y: self.y.add(rhs),
1407 z: self.z.add(rhs),
1408 w: self.w.add(rhs),
1409 }
1410 }
1411}
1412
1413impl Add<&i8> for I8Vec4 {
1414 type Output = Self;
1415 #[inline]
1416 fn add(self, rhs: &i8) -> Self {
1417 self.add(*rhs)
1418 }
1419}
1420
1421impl Add<&i8> for &I8Vec4 {
1422 type Output = I8Vec4;
1423 #[inline]
1424 fn add(self, rhs: &i8) -> I8Vec4 {
1425 (*self).add(*rhs)
1426 }
1427}
1428
1429impl Add<i8> for &I8Vec4 {
1430 type Output = I8Vec4;
1431 #[inline]
1432 fn add(self, rhs: i8) -> I8Vec4 {
1433 (*self).add(rhs)
1434 }
1435}
1436
1437impl AddAssign<i8> for I8Vec4 {
1438 #[inline]
1439 fn add_assign(&mut self, rhs: i8) {
1440 self.x.add_assign(rhs);
1441 self.y.add_assign(rhs);
1442 self.z.add_assign(rhs);
1443 self.w.add_assign(rhs);
1444 }
1445}
1446
1447impl AddAssign<&i8> for I8Vec4 {
1448 #[inline]
1449 fn add_assign(&mut self, rhs: &i8) {
1450 self.add_assign(*rhs);
1451 }
1452}
1453
1454impl Add<I8Vec4> for i8 {
1455 type Output = I8Vec4;
1456 #[inline]
1457 fn add(self, rhs: I8Vec4) -> I8Vec4 {
1458 I8Vec4 {
1459 x: self.add(rhs.x),
1460 y: self.add(rhs.y),
1461 z: self.add(rhs.z),
1462 w: self.add(rhs.w),
1463 }
1464 }
1465}
1466
1467impl Add<&I8Vec4> for i8 {
1468 type Output = I8Vec4;
1469 #[inline]
1470 fn add(self, rhs: &I8Vec4) -> I8Vec4 {
1471 self.add(*rhs)
1472 }
1473}
1474
1475impl Add<&I8Vec4> for &i8 {
1476 type Output = I8Vec4;
1477 #[inline]
1478 fn add(self, rhs: &I8Vec4) -> I8Vec4 {
1479 (*self).add(*rhs)
1480 }
1481}
1482
1483impl Add<I8Vec4> for &i8 {
1484 type Output = I8Vec4;
1485 #[inline]
1486 fn add(self, rhs: I8Vec4) -> I8Vec4 {
1487 (*self).add(rhs)
1488 }
1489}
1490
1491impl Sub for I8Vec4 {
1492 type Output = Self;
1493 #[inline]
1494 fn sub(self, rhs: Self) -> Self {
1495 Self {
1496 x: self.x.sub(rhs.x),
1497 y: self.y.sub(rhs.y),
1498 z: self.z.sub(rhs.z),
1499 w: self.w.sub(rhs.w),
1500 }
1501 }
1502}
1503
1504impl Sub<&Self> for I8Vec4 {
1505 type Output = Self;
1506 #[inline]
1507 fn sub(self, rhs: &Self) -> Self {
1508 self.sub(*rhs)
1509 }
1510}
1511
1512impl Sub<&I8Vec4> for &I8Vec4 {
1513 type Output = I8Vec4;
1514 #[inline]
1515 fn sub(self, rhs: &I8Vec4) -> I8Vec4 {
1516 (*self).sub(*rhs)
1517 }
1518}
1519
1520impl Sub<I8Vec4> for &I8Vec4 {
1521 type Output = I8Vec4;
1522 #[inline]
1523 fn sub(self, rhs: I8Vec4) -> I8Vec4 {
1524 (*self).sub(rhs)
1525 }
1526}
1527
1528impl SubAssign for I8Vec4 {
1529 #[inline]
1530 fn sub_assign(&mut self, rhs: Self) {
1531 self.x.sub_assign(rhs.x);
1532 self.y.sub_assign(rhs.y);
1533 self.z.sub_assign(rhs.z);
1534 self.w.sub_assign(rhs.w);
1535 }
1536}
1537
1538impl SubAssign<&Self> for I8Vec4 {
1539 #[inline]
1540 fn sub_assign(&mut self, rhs: &Self) {
1541 self.sub_assign(*rhs);
1542 }
1543}
1544
1545impl Sub<i8> for I8Vec4 {
1546 type Output = Self;
1547 #[inline]
1548 fn sub(self, rhs: i8) -> Self {
1549 Self {
1550 x: self.x.sub(rhs),
1551 y: self.y.sub(rhs),
1552 z: self.z.sub(rhs),
1553 w: self.w.sub(rhs),
1554 }
1555 }
1556}
1557
1558impl Sub<&i8> for I8Vec4 {
1559 type Output = Self;
1560 #[inline]
1561 fn sub(self, rhs: &i8) -> Self {
1562 self.sub(*rhs)
1563 }
1564}
1565
1566impl Sub<&i8> for &I8Vec4 {
1567 type Output = I8Vec4;
1568 #[inline]
1569 fn sub(self, rhs: &i8) -> I8Vec4 {
1570 (*self).sub(*rhs)
1571 }
1572}
1573
1574impl Sub<i8> for &I8Vec4 {
1575 type Output = I8Vec4;
1576 #[inline]
1577 fn sub(self, rhs: i8) -> I8Vec4 {
1578 (*self).sub(rhs)
1579 }
1580}
1581
1582impl SubAssign<i8> for I8Vec4 {
1583 #[inline]
1584 fn sub_assign(&mut self, rhs: i8) {
1585 self.x.sub_assign(rhs);
1586 self.y.sub_assign(rhs);
1587 self.z.sub_assign(rhs);
1588 self.w.sub_assign(rhs);
1589 }
1590}
1591
1592impl SubAssign<&i8> for I8Vec4 {
1593 #[inline]
1594 fn sub_assign(&mut self, rhs: &i8) {
1595 self.sub_assign(*rhs);
1596 }
1597}
1598
1599impl Sub<I8Vec4> for i8 {
1600 type Output = I8Vec4;
1601 #[inline]
1602 fn sub(self, rhs: I8Vec4) -> I8Vec4 {
1603 I8Vec4 {
1604 x: self.sub(rhs.x),
1605 y: self.sub(rhs.y),
1606 z: self.sub(rhs.z),
1607 w: self.sub(rhs.w),
1608 }
1609 }
1610}
1611
1612impl Sub<&I8Vec4> for i8 {
1613 type Output = I8Vec4;
1614 #[inline]
1615 fn sub(self, rhs: &I8Vec4) -> I8Vec4 {
1616 self.sub(*rhs)
1617 }
1618}
1619
1620impl Sub<&I8Vec4> for &i8 {
1621 type Output = I8Vec4;
1622 #[inline]
1623 fn sub(self, rhs: &I8Vec4) -> I8Vec4 {
1624 (*self).sub(*rhs)
1625 }
1626}
1627
1628impl Sub<I8Vec4> for &i8 {
1629 type Output = I8Vec4;
1630 #[inline]
1631 fn sub(self, rhs: I8Vec4) -> I8Vec4 {
1632 (*self).sub(rhs)
1633 }
1634}
1635
1636impl Rem for I8Vec4 {
1637 type Output = Self;
1638 #[inline]
1639 fn rem(self, rhs: Self) -> Self {
1640 Self {
1641 x: self.x.rem(rhs.x),
1642 y: self.y.rem(rhs.y),
1643 z: self.z.rem(rhs.z),
1644 w: self.w.rem(rhs.w),
1645 }
1646 }
1647}
1648
1649impl Rem<&Self> for I8Vec4 {
1650 type Output = Self;
1651 #[inline]
1652 fn rem(self, rhs: &Self) -> Self {
1653 self.rem(*rhs)
1654 }
1655}
1656
1657impl Rem<&I8Vec4> for &I8Vec4 {
1658 type Output = I8Vec4;
1659 #[inline]
1660 fn rem(self, rhs: &I8Vec4) -> I8Vec4 {
1661 (*self).rem(*rhs)
1662 }
1663}
1664
1665impl Rem<I8Vec4> for &I8Vec4 {
1666 type Output = I8Vec4;
1667 #[inline]
1668 fn rem(self, rhs: I8Vec4) -> I8Vec4 {
1669 (*self).rem(rhs)
1670 }
1671}
1672
1673impl RemAssign for I8Vec4 {
1674 #[inline]
1675 fn rem_assign(&mut self, rhs: Self) {
1676 self.x.rem_assign(rhs.x);
1677 self.y.rem_assign(rhs.y);
1678 self.z.rem_assign(rhs.z);
1679 self.w.rem_assign(rhs.w);
1680 }
1681}
1682
1683impl RemAssign<&Self> for I8Vec4 {
1684 #[inline]
1685 fn rem_assign(&mut self, rhs: &Self) {
1686 self.rem_assign(*rhs);
1687 }
1688}
1689
1690impl Rem<i8> for I8Vec4 {
1691 type Output = Self;
1692 #[inline]
1693 fn rem(self, rhs: i8) -> Self {
1694 Self {
1695 x: self.x.rem(rhs),
1696 y: self.y.rem(rhs),
1697 z: self.z.rem(rhs),
1698 w: self.w.rem(rhs),
1699 }
1700 }
1701}
1702
1703impl Rem<&i8> for I8Vec4 {
1704 type Output = Self;
1705 #[inline]
1706 fn rem(self, rhs: &i8) -> Self {
1707 self.rem(*rhs)
1708 }
1709}
1710
1711impl Rem<&i8> for &I8Vec4 {
1712 type Output = I8Vec4;
1713 #[inline]
1714 fn rem(self, rhs: &i8) -> I8Vec4 {
1715 (*self).rem(*rhs)
1716 }
1717}
1718
1719impl Rem<i8> for &I8Vec4 {
1720 type Output = I8Vec4;
1721 #[inline]
1722 fn rem(self, rhs: i8) -> I8Vec4 {
1723 (*self).rem(rhs)
1724 }
1725}
1726
1727impl RemAssign<i8> for I8Vec4 {
1728 #[inline]
1729 fn rem_assign(&mut self, rhs: i8) {
1730 self.x.rem_assign(rhs);
1731 self.y.rem_assign(rhs);
1732 self.z.rem_assign(rhs);
1733 self.w.rem_assign(rhs);
1734 }
1735}
1736
1737impl RemAssign<&i8> for I8Vec4 {
1738 #[inline]
1739 fn rem_assign(&mut self, rhs: &i8) {
1740 self.rem_assign(*rhs);
1741 }
1742}
1743
1744impl Rem<I8Vec4> for i8 {
1745 type Output = I8Vec4;
1746 #[inline]
1747 fn rem(self, rhs: I8Vec4) -> I8Vec4 {
1748 I8Vec4 {
1749 x: self.rem(rhs.x),
1750 y: self.rem(rhs.y),
1751 z: self.rem(rhs.z),
1752 w: self.rem(rhs.w),
1753 }
1754 }
1755}
1756
1757impl Rem<&I8Vec4> for i8 {
1758 type Output = I8Vec4;
1759 #[inline]
1760 fn rem(self, rhs: &I8Vec4) -> I8Vec4 {
1761 self.rem(*rhs)
1762 }
1763}
1764
1765impl Rem<&I8Vec4> for &i8 {
1766 type Output = I8Vec4;
1767 #[inline]
1768 fn rem(self, rhs: &I8Vec4) -> I8Vec4 {
1769 (*self).rem(*rhs)
1770 }
1771}
1772
1773impl Rem<I8Vec4> for &i8 {
1774 type Output = I8Vec4;
1775 #[inline]
1776 fn rem(self, rhs: I8Vec4) -> I8Vec4 {
1777 (*self).rem(rhs)
1778 }
1779}
1780
1781impl AsRef<[i8; 4]> for I8Vec4 {
1782 #[inline]
1783 fn as_ref(&self) -> &[i8; 4] {
1784 unsafe { &*(self as *const Self as *const [i8; 4]) }
1785 }
1786}
1787
1788impl AsMut<[i8; 4]> for I8Vec4 {
1789 #[inline]
1790 fn as_mut(&mut self) -> &mut [i8; 4] {
1791 unsafe { &mut *(self as *mut Self as *mut [i8; 4]) }
1792 }
1793}
1794
1795impl Sum for I8Vec4 {
1796 #[inline]
1797 fn sum<I>(iter: I) -> Self
1798 where
1799 I: Iterator<Item = Self>,
1800 {
1801 iter.fold(Self::ZERO, Self::add)
1802 }
1803}
1804
1805impl<'a> Sum<&'a Self> for I8Vec4 {
1806 #[inline]
1807 fn sum<I>(iter: I) -> Self
1808 where
1809 I: Iterator<Item = &'a Self>,
1810 {
1811 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1812 }
1813}
1814
1815impl Product for I8Vec4 {
1816 #[inline]
1817 fn product<I>(iter: I) -> Self
1818 where
1819 I: Iterator<Item = Self>,
1820 {
1821 iter.fold(Self::ONE, Self::mul)
1822 }
1823}
1824
1825impl<'a> Product<&'a Self> for I8Vec4 {
1826 #[inline]
1827 fn product<I>(iter: I) -> Self
1828 where
1829 I: Iterator<Item = &'a Self>,
1830 {
1831 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1832 }
1833}
1834
1835impl Neg for I8Vec4 {
1836 type Output = Self;
1837 #[inline]
1838 fn neg(self) -> Self {
1839 Self {
1840 x: self.x.neg(),
1841 y: self.y.neg(),
1842 z: self.z.neg(),
1843 w: self.w.neg(),
1844 }
1845 }
1846}
1847
1848impl Neg for &I8Vec4 {
1849 type Output = I8Vec4;
1850 #[inline]
1851 fn neg(self) -> I8Vec4 {
1852 (*self).neg()
1853 }
1854}
1855
1856impl Not for I8Vec4 {
1857 type Output = Self;
1858 #[inline]
1859 fn not(self) -> Self {
1860 Self {
1861 x: self.x.not(),
1862 y: self.y.not(),
1863 z: self.z.not(),
1864 w: self.w.not(),
1865 }
1866 }
1867}
1868
1869impl Not for &I8Vec4 {
1870 type Output = I8Vec4;
1871 #[inline]
1872 fn not(self) -> I8Vec4 {
1873 (*self).not()
1874 }
1875}
1876
1877impl BitAnd for I8Vec4 {
1878 type Output = Self;
1879 #[inline]
1880 fn bitand(self, rhs: Self) -> Self::Output {
1881 Self {
1882 x: self.x.bitand(rhs.x),
1883 y: self.y.bitand(rhs.y),
1884 z: self.z.bitand(rhs.z),
1885 w: self.w.bitand(rhs.w),
1886 }
1887 }
1888}
1889
1890impl BitAnd<&Self> for I8Vec4 {
1891 type Output = Self;
1892 #[inline]
1893 fn bitand(self, rhs: &Self) -> Self {
1894 self.bitand(*rhs)
1895 }
1896}
1897
1898impl BitAnd<&I8Vec4> for &I8Vec4 {
1899 type Output = I8Vec4;
1900 #[inline]
1901 fn bitand(self, rhs: &I8Vec4) -> I8Vec4 {
1902 (*self).bitand(*rhs)
1903 }
1904}
1905
1906impl BitAnd<I8Vec4> for &I8Vec4 {
1907 type Output = I8Vec4;
1908 #[inline]
1909 fn bitand(self, rhs: I8Vec4) -> I8Vec4 {
1910 (*self).bitand(rhs)
1911 }
1912}
1913
1914impl BitAndAssign for I8Vec4 {
1915 #[inline]
1916 fn bitand_assign(&mut self, rhs: Self) {
1917 *self = self.bitand(rhs);
1918 }
1919}
1920
1921impl BitAndAssign<&Self> for I8Vec4 {
1922 #[inline]
1923 fn bitand_assign(&mut self, rhs: &Self) {
1924 self.bitand_assign(*rhs);
1925 }
1926}
1927
1928impl BitOr for I8Vec4 {
1929 type Output = Self;
1930 #[inline]
1931 fn bitor(self, rhs: Self) -> Self::Output {
1932 Self {
1933 x: self.x.bitor(rhs.x),
1934 y: self.y.bitor(rhs.y),
1935 z: self.z.bitor(rhs.z),
1936 w: self.w.bitor(rhs.w),
1937 }
1938 }
1939}
1940
1941impl BitOr<&Self> for I8Vec4 {
1942 type Output = Self;
1943 #[inline]
1944 fn bitor(self, rhs: &Self) -> Self {
1945 self.bitor(*rhs)
1946 }
1947}
1948
1949impl BitOr<&I8Vec4> for &I8Vec4 {
1950 type Output = I8Vec4;
1951 #[inline]
1952 fn bitor(self, rhs: &I8Vec4) -> I8Vec4 {
1953 (*self).bitor(*rhs)
1954 }
1955}
1956
1957impl BitOr<I8Vec4> for &I8Vec4 {
1958 type Output = I8Vec4;
1959 #[inline]
1960 fn bitor(self, rhs: I8Vec4) -> I8Vec4 {
1961 (*self).bitor(rhs)
1962 }
1963}
1964
1965impl BitOrAssign for I8Vec4 {
1966 #[inline]
1967 fn bitor_assign(&mut self, rhs: Self) {
1968 *self = self.bitor(rhs);
1969 }
1970}
1971
1972impl BitOrAssign<&Self> for I8Vec4 {
1973 #[inline]
1974 fn bitor_assign(&mut self, rhs: &Self) {
1975 self.bitor_assign(*rhs);
1976 }
1977}
1978
1979impl BitXor for I8Vec4 {
1980 type Output = Self;
1981 #[inline]
1982 fn bitxor(self, rhs: Self) -> Self::Output {
1983 Self {
1984 x: self.x.bitxor(rhs.x),
1985 y: self.y.bitxor(rhs.y),
1986 z: self.z.bitxor(rhs.z),
1987 w: self.w.bitxor(rhs.w),
1988 }
1989 }
1990}
1991
1992impl BitXor<&Self> for I8Vec4 {
1993 type Output = Self;
1994 #[inline]
1995 fn bitxor(self, rhs: &Self) -> Self {
1996 self.bitxor(*rhs)
1997 }
1998}
1999
2000impl BitXor<&I8Vec4> for &I8Vec4 {
2001 type Output = I8Vec4;
2002 #[inline]
2003 fn bitxor(self, rhs: &I8Vec4) -> I8Vec4 {
2004 (*self).bitxor(*rhs)
2005 }
2006}
2007
2008impl BitXor<I8Vec4> for &I8Vec4 {
2009 type Output = I8Vec4;
2010 #[inline]
2011 fn bitxor(self, rhs: I8Vec4) -> I8Vec4 {
2012 (*self).bitxor(rhs)
2013 }
2014}
2015
2016impl BitXorAssign for I8Vec4 {
2017 #[inline]
2018 fn bitxor_assign(&mut self, rhs: Self) {
2019 *self = self.bitxor(rhs);
2020 }
2021}
2022
2023impl BitXorAssign<&Self> for I8Vec4 {
2024 #[inline]
2025 fn bitxor_assign(&mut self, rhs: &Self) {
2026 self.bitxor_assign(*rhs);
2027 }
2028}
2029
2030impl BitAnd<i8> for I8Vec4 {
2031 type Output = Self;
2032 #[inline]
2033 fn bitand(self, rhs: i8) -> Self::Output {
2034 Self {
2035 x: self.x.bitand(rhs),
2036 y: self.y.bitand(rhs),
2037 z: self.z.bitand(rhs),
2038 w: self.w.bitand(rhs),
2039 }
2040 }
2041}
2042
2043impl BitAnd<&i8> for I8Vec4 {
2044 type Output = Self;
2045 #[inline]
2046 fn bitand(self, rhs: &i8) -> Self {
2047 self.bitand(*rhs)
2048 }
2049}
2050
2051impl BitAnd<&i8> for &I8Vec4 {
2052 type Output = I8Vec4;
2053 #[inline]
2054 fn bitand(self, rhs: &i8) -> I8Vec4 {
2055 (*self).bitand(*rhs)
2056 }
2057}
2058
2059impl BitAnd<i8> for &I8Vec4 {
2060 type Output = I8Vec4;
2061 #[inline]
2062 fn bitand(self, rhs: i8) -> I8Vec4 {
2063 (*self).bitand(rhs)
2064 }
2065}
2066
2067impl BitAndAssign<i8> for I8Vec4 {
2068 #[inline]
2069 fn bitand_assign(&mut self, rhs: i8) {
2070 *self = self.bitand(rhs);
2071 }
2072}
2073
2074impl BitAndAssign<&i8> for I8Vec4 {
2075 #[inline]
2076 fn bitand_assign(&mut self, rhs: &i8) {
2077 self.bitand_assign(*rhs);
2078 }
2079}
2080
2081impl BitOr<i8> for I8Vec4 {
2082 type Output = Self;
2083 #[inline]
2084 fn bitor(self, rhs: i8) -> Self::Output {
2085 Self {
2086 x: self.x.bitor(rhs),
2087 y: self.y.bitor(rhs),
2088 z: self.z.bitor(rhs),
2089 w: self.w.bitor(rhs),
2090 }
2091 }
2092}
2093
2094impl BitOr<&i8> for I8Vec4 {
2095 type Output = Self;
2096 #[inline]
2097 fn bitor(self, rhs: &i8) -> Self {
2098 self.bitor(*rhs)
2099 }
2100}
2101
2102impl BitOr<&i8> for &I8Vec4 {
2103 type Output = I8Vec4;
2104 #[inline]
2105 fn bitor(self, rhs: &i8) -> I8Vec4 {
2106 (*self).bitor(*rhs)
2107 }
2108}
2109
2110impl BitOr<i8> for &I8Vec4 {
2111 type Output = I8Vec4;
2112 #[inline]
2113 fn bitor(self, rhs: i8) -> I8Vec4 {
2114 (*self).bitor(rhs)
2115 }
2116}
2117
2118impl BitOrAssign<i8> for I8Vec4 {
2119 #[inline]
2120 fn bitor_assign(&mut self, rhs: i8) {
2121 *self = self.bitor(rhs);
2122 }
2123}
2124
2125impl BitOrAssign<&i8> for I8Vec4 {
2126 #[inline]
2127 fn bitor_assign(&mut self, rhs: &i8) {
2128 self.bitor_assign(*rhs);
2129 }
2130}
2131
2132impl BitXor<i8> for I8Vec4 {
2133 type Output = Self;
2134 #[inline]
2135 fn bitxor(self, rhs: i8) -> Self::Output {
2136 Self {
2137 x: self.x.bitxor(rhs),
2138 y: self.y.bitxor(rhs),
2139 z: self.z.bitxor(rhs),
2140 w: self.w.bitxor(rhs),
2141 }
2142 }
2143}
2144
2145impl BitXor<&i8> for I8Vec4 {
2146 type Output = Self;
2147 #[inline]
2148 fn bitxor(self, rhs: &i8) -> Self {
2149 self.bitxor(*rhs)
2150 }
2151}
2152
2153impl BitXor<&i8> for &I8Vec4 {
2154 type Output = I8Vec4;
2155 #[inline]
2156 fn bitxor(self, rhs: &i8) -> I8Vec4 {
2157 (*self).bitxor(*rhs)
2158 }
2159}
2160
2161impl BitXor<i8> for &I8Vec4 {
2162 type Output = I8Vec4;
2163 #[inline]
2164 fn bitxor(self, rhs: i8) -> I8Vec4 {
2165 (*self).bitxor(rhs)
2166 }
2167}
2168
2169impl BitXorAssign<i8> for I8Vec4 {
2170 #[inline]
2171 fn bitxor_assign(&mut self, rhs: i8) {
2172 *self = self.bitxor(rhs);
2173 }
2174}
2175
2176impl BitXorAssign<&i8> for I8Vec4 {
2177 #[inline]
2178 fn bitxor_assign(&mut self, rhs: &i8) {
2179 self.bitxor_assign(*rhs);
2180 }
2181}
2182
2183impl Shl<i8> for I8Vec4 {
2184 type Output = Self;
2185 #[inline]
2186 fn shl(self, rhs: i8) -> Self::Output {
2187 Self {
2188 x: self.x.shl(rhs),
2189 y: self.y.shl(rhs),
2190 z: self.z.shl(rhs),
2191 w: self.w.shl(rhs),
2192 }
2193 }
2194}
2195
2196impl Shl<&i8> for I8Vec4 {
2197 type Output = Self;
2198 #[inline]
2199 fn shl(self, rhs: &i8) -> Self {
2200 self.shl(*rhs)
2201 }
2202}
2203
2204impl Shl<&i8> for &I8Vec4 {
2205 type Output = I8Vec4;
2206 #[inline]
2207 fn shl(self, rhs: &i8) -> I8Vec4 {
2208 (*self).shl(*rhs)
2209 }
2210}
2211
2212impl Shl<i8> for &I8Vec4 {
2213 type Output = I8Vec4;
2214 #[inline]
2215 fn shl(self, rhs: i8) -> I8Vec4 {
2216 (*self).shl(rhs)
2217 }
2218}
2219
2220impl ShlAssign<i8> for I8Vec4 {
2221 #[inline]
2222 fn shl_assign(&mut self, rhs: i8) {
2223 *self = self.shl(rhs);
2224 }
2225}
2226
2227impl ShlAssign<&i8> for I8Vec4 {
2228 #[inline]
2229 fn shl_assign(&mut self, rhs: &i8) {
2230 self.shl_assign(*rhs);
2231 }
2232}
2233
2234impl Shr<i8> for I8Vec4 {
2235 type Output = Self;
2236 #[inline]
2237 fn shr(self, rhs: i8) -> Self::Output {
2238 Self {
2239 x: self.x.shr(rhs),
2240 y: self.y.shr(rhs),
2241 z: self.z.shr(rhs),
2242 w: self.w.shr(rhs),
2243 }
2244 }
2245}
2246
2247impl Shr<&i8> for I8Vec4 {
2248 type Output = Self;
2249 #[inline]
2250 fn shr(self, rhs: &i8) -> Self {
2251 self.shr(*rhs)
2252 }
2253}
2254
2255impl Shr<&i8> for &I8Vec4 {
2256 type Output = I8Vec4;
2257 #[inline]
2258 fn shr(self, rhs: &i8) -> I8Vec4 {
2259 (*self).shr(*rhs)
2260 }
2261}
2262
2263impl Shr<i8> for &I8Vec4 {
2264 type Output = I8Vec4;
2265 #[inline]
2266 fn shr(self, rhs: i8) -> I8Vec4 {
2267 (*self).shr(rhs)
2268 }
2269}
2270
2271impl ShrAssign<i8> for I8Vec4 {
2272 #[inline]
2273 fn shr_assign(&mut self, rhs: i8) {
2274 *self = self.shr(rhs);
2275 }
2276}
2277
2278impl ShrAssign<&i8> for I8Vec4 {
2279 #[inline]
2280 fn shr_assign(&mut self, rhs: &i8) {
2281 self.shr_assign(*rhs);
2282 }
2283}
2284
2285impl Shl<i16> for I8Vec4 {
2286 type Output = Self;
2287 #[inline]
2288 fn shl(self, rhs: i16) -> Self::Output {
2289 Self {
2290 x: self.x.shl(rhs),
2291 y: self.y.shl(rhs),
2292 z: self.z.shl(rhs),
2293 w: self.w.shl(rhs),
2294 }
2295 }
2296}
2297
2298impl Shl<&i16> for I8Vec4 {
2299 type Output = Self;
2300 #[inline]
2301 fn shl(self, rhs: &i16) -> Self {
2302 self.shl(*rhs)
2303 }
2304}
2305
2306impl Shl<&i16> for &I8Vec4 {
2307 type Output = I8Vec4;
2308 #[inline]
2309 fn shl(self, rhs: &i16) -> I8Vec4 {
2310 (*self).shl(*rhs)
2311 }
2312}
2313
2314impl Shl<i16> for &I8Vec4 {
2315 type Output = I8Vec4;
2316 #[inline]
2317 fn shl(self, rhs: i16) -> I8Vec4 {
2318 (*self).shl(rhs)
2319 }
2320}
2321
2322impl ShlAssign<i16> for I8Vec4 {
2323 #[inline]
2324 fn shl_assign(&mut self, rhs: i16) {
2325 *self = self.shl(rhs);
2326 }
2327}
2328
2329impl ShlAssign<&i16> for I8Vec4 {
2330 #[inline]
2331 fn shl_assign(&mut self, rhs: &i16) {
2332 self.shl_assign(*rhs);
2333 }
2334}
2335
2336impl Shr<i16> for I8Vec4 {
2337 type Output = Self;
2338 #[inline]
2339 fn shr(self, rhs: i16) -> Self::Output {
2340 Self {
2341 x: self.x.shr(rhs),
2342 y: self.y.shr(rhs),
2343 z: self.z.shr(rhs),
2344 w: self.w.shr(rhs),
2345 }
2346 }
2347}
2348
2349impl Shr<&i16> for I8Vec4 {
2350 type Output = Self;
2351 #[inline]
2352 fn shr(self, rhs: &i16) -> Self {
2353 self.shr(*rhs)
2354 }
2355}
2356
2357impl Shr<&i16> for &I8Vec4 {
2358 type Output = I8Vec4;
2359 #[inline]
2360 fn shr(self, rhs: &i16) -> I8Vec4 {
2361 (*self).shr(*rhs)
2362 }
2363}
2364
2365impl Shr<i16> for &I8Vec4 {
2366 type Output = I8Vec4;
2367 #[inline]
2368 fn shr(self, rhs: i16) -> I8Vec4 {
2369 (*self).shr(rhs)
2370 }
2371}
2372
2373impl ShrAssign<i16> for I8Vec4 {
2374 #[inline]
2375 fn shr_assign(&mut self, rhs: i16) {
2376 *self = self.shr(rhs);
2377 }
2378}
2379
2380impl ShrAssign<&i16> for I8Vec4 {
2381 #[inline]
2382 fn shr_assign(&mut self, rhs: &i16) {
2383 self.shr_assign(*rhs);
2384 }
2385}
2386
2387impl Shl<i32> for I8Vec4 {
2388 type Output = Self;
2389 #[inline]
2390 fn shl(self, rhs: i32) -> Self::Output {
2391 Self {
2392 x: self.x.shl(rhs),
2393 y: self.y.shl(rhs),
2394 z: self.z.shl(rhs),
2395 w: self.w.shl(rhs),
2396 }
2397 }
2398}
2399
2400impl Shl<&i32> for I8Vec4 {
2401 type Output = Self;
2402 #[inline]
2403 fn shl(self, rhs: &i32) -> Self {
2404 self.shl(*rhs)
2405 }
2406}
2407
2408impl Shl<&i32> for &I8Vec4 {
2409 type Output = I8Vec4;
2410 #[inline]
2411 fn shl(self, rhs: &i32) -> I8Vec4 {
2412 (*self).shl(*rhs)
2413 }
2414}
2415
2416impl Shl<i32> for &I8Vec4 {
2417 type Output = I8Vec4;
2418 #[inline]
2419 fn shl(self, rhs: i32) -> I8Vec4 {
2420 (*self).shl(rhs)
2421 }
2422}
2423
2424impl ShlAssign<i32> for I8Vec4 {
2425 #[inline]
2426 fn shl_assign(&mut self, rhs: i32) {
2427 *self = self.shl(rhs);
2428 }
2429}
2430
2431impl ShlAssign<&i32> for I8Vec4 {
2432 #[inline]
2433 fn shl_assign(&mut self, rhs: &i32) {
2434 self.shl_assign(*rhs);
2435 }
2436}
2437
2438impl Shr<i32> for I8Vec4 {
2439 type Output = Self;
2440 #[inline]
2441 fn shr(self, rhs: i32) -> Self::Output {
2442 Self {
2443 x: self.x.shr(rhs),
2444 y: self.y.shr(rhs),
2445 z: self.z.shr(rhs),
2446 w: self.w.shr(rhs),
2447 }
2448 }
2449}
2450
2451impl Shr<&i32> for I8Vec4 {
2452 type Output = Self;
2453 #[inline]
2454 fn shr(self, rhs: &i32) -> Self {
2455 self.shr(*rhs)
2456 }
2457}
2458
2459impl Shr<&i32> for &I8Vec4 {
2460 type Output = I8Vec4;
2461 #[inline]
2462 fn shr(self, rhs: &i32) -> I8Vec4 {
2463 (*self).shr(*rhs)
2464 }
2465}
2466
2467impl Shr<i32> for &I8Vec4 {
2468 type Output = I8Vec4;
2469 #[inline]
2470 fn shr(self, rhs: i32) -> I8Vec4 {
2471 (*self).shr(rhs)
2472 }
2473}
2474
2475impl ShrAssign<i32> for I8Vec4 {
2476 #[inline]
2477 fn shr_assign(&mut self, rhs: i32) {
2478 *self = self.shr(rhs);
2479 }
2480}
2481
2482impl ShrAssign<&i32> for I8Vec4 {
2483 #[inline]
2484 fn shr_assign(&mut self, rhs: &i32) {
2485 self.shr_assign(*rhs);
2486 }
2487}
2488
2489impl Shl<i64> for I8Vec4 {
2490 type Output = Self;
2491 #[inline]
2492 fn shl(self, rhs: i64) -> Self::Output {
2493 Self {
2494 x: self.x.shl(rhs),
2495 y: self.y.shl(rhs),
2496 z: self.z.shl(rhs),
2497 w: self.w.shl(rhs),
2498 }
2499 }
2500}
2501
2502impl Shl<&i64> for I8Vec4 {
2503 type Output = Self;
2504 #[inline]
2505 fn shl(self, rhs: &i64) -> Self {
2506 self.shl(*rhs)
2507 }
2508}
2509
2510impl Shl<&i64> for &I8Vec4 {
2511 type Output = I8Vec4;
2512 #[inline]
2513 fn shl(self, rhs: &i64) -> I8Vec4 {
2514 (*self).shl(*rhs)
2515 }
2516}
2517
2518impl Shl<i64> for &I8Vec4 {
2519 type Output = I8Vec4;
2520 #[inline]
2521 fn shl(self, rhs: i64) -> I8Vec4 {
2522 (*self).shl(rhs)
2523 }
2524}
2525
2526impl ShlAssign<i64> for I8Vec4 {
2527 #[inline]
2528 fn shl_assign(&mut self, rhs: i64) {
2529 *self = self.shl(rhs);
2530 }
2531}
2532
2533impl ShlAssign<&i64> for I8Vec4 {
2534 #[inline]
2535 fn shl_assign(&mut self, rhs: &i64) {
2536 self.shl_assign(*rhs);
2537 }
2538}
2539
2540impl Shr<i64> for I8Vec4 {
2541 type Output = Self;
2542 #[inline]
2543 fn shr(self, rhs: i64) -> Self::Output {
2544 Self {
2545 x: self.x.shr(rhs),
2546 y: self.y.shr(rhs),
2547 z: self.z.shr(rhs),
2548 w: self.w.shr(rhs),
2549 }
2550 }
2551}
2552
2553impl Shr<&i64> for I8Vec4 {
2554 type Output = Self;
2555 #[inline]
2556 fn shr(self, rhs: &i64) -> Self {
2557 self.shr(*rhs)
2558 }
2559}
2560
2561impl Shr<&i64> for &I8Vec4 {
2562 type Output = I8Vec4;
2563 #[inline]
2564 fn shr(self, rhs: &i64) -> I8Vec4 {
2565 (*self).shr(*rhs)
2566 }
2567}
2568
2569impl Shr<i64> for &I8Vec4 {
2570 type Output = I8Vec4;
2571 #[inline]
2572 fn shr(self, rhs: i64) -> I8Vec4 {
2573 (*self).shr(rhs)
2574 }
2575}
2576
2577impl ShrAssign<i64> for I8Vec4 {
2578 #[inline]
2579 fn shr_assign(&mut self, rhs: i64) {
2580 *self = self.shr(rhs);
2581 }
2582}
2583
2584impl ShrAssign<&i64> for I8Vec4 {
2585 #[inline]
2586 fn shr_assign(&mut self, rhs: &i64) {
2587 self.shr_assign(*rhs);
2588 }
2589}
2590
2591impl Shl<u8> for I8Vec4 {
2592 type Output = Self;
2593 #[inline]
2594 fn shl(self, rhs: u8) -> Self::Output {
2595 Self {
2596 x: self.x.shl(rhs),
2597 y: self.y.shl(rhs),
2598 z: self.z.shl(rhs),
2599 w: self.w.shl(rhs),
2600 }
2601 }
2602}
2603
2604impl Shl<&u8> for I8Vec4 {
2605 type Output = Self;
2606 #[inline]
2607 fn shl(self, rhs: &u8) -> Self {
2608 self.shl(*rhs)
2609 }
2610}
2611
2612impl Shl<&u8> for &I8Vec4 {
2613 type Output = I8Vec4;
2614 #[inline]
2615 fn shl(self, rhs: &u8) -> I8Vec4 {
2616 (*self).shl(*rhs)
2617 }
2618}
2619
2620impl Shl<u8> for &I8Vec4 {
2621 type Output = I8Vec4;
2622 #[inline]
2623 fn shl(self, rhs: u8) -> I8Vec4 {
2624 (*self).shl(rhs)
2625 }
2626}
2627
2628impl ShlAssign<u8> for I8Vec4 {
2629 #[inline]
2630 fn shl_assign(&mut self, rhs: u8) {
2631 *self = self.shl(rhs);
2632 }
2633}
2634
2635impl ShlAssign<&u8> for I8Vec4 {
2636 #[inline]
2637 fn shl_assign(&mut self, rhs: &u8) {
2638 self.shl_assign(*rhs);
2639 }
2640}
2641
2642impl Shr<u8> for I8Vec4 {
2643 type Output = Self;
2644 #[inline]
2645 fn shr(self, rhs: u8) -> Self::Output {
2646 Self {
2647 x: self.x.shr(rhs),
2648 y: self.y.shr(rhs),
2649 z: self.z.shr(rhs),
2650 w: self.w.shr(rhs),
2651 }
2652 }
2653}
2654
2655impl Shr<&u8> for I8Vec4 {
2656 type Output = Self;
2657 #[inline]
2658 fn shr(self, rhs: &u8) -> Self {
2659 self.shr(*rhs)
2660 }
2661}
2662
2663impl Shr<&u8> for &I8Vec4 {
2664 type Output = I8Vec4;
2665 #[inline]
2666 fn shr(self, rhs: &u8) -> I8Vec4 {
2667 (*self).shr(*rhs)
2668 }
2669}
2670
2671impl Shr<u8> for &I8Vec4 {
2672 type Output = I8Vec4;
2673 #[inline]
2674 fn shr(self, rhs: u8) -> I8Vec4 {
2675 (*self).shr(rhs)
2676 }
2677}
2678
2679impl ShrAssign<u8> for I8Vec4 {
2680 #[inline]
2681 fn shr_assign(&mut self, rhs: u8) {
2682 *self = self.shr(rhs);
2683 }
2684}
2685
2686impl ShrAssign<&u8> for I8Vec4 {
2687 #[inline]
2688 fn shr_assign(&mut self, rhs: &u8) {
2689 self.shr_assign(*rhs);
2690 }
2691}
2692
2693impl Shl<u16> for I8Vec4 {
2694 type Output = Self;
2695 #[inline]
2696 fn shl(self, rhs: u16) -> Self::Output {
2697 Self {
2698 x: self.x.shl(rhs),
2699 y: self.y.shl(rhs),
2700 z: self.z.shl(rhs),
2701 w: self.w.shl(rhs),
2702 }
2703 }
2704}
2705
2706impl Shl<&u16> for I8Vec4 {
2707 type Output = Self;
2708 #[inline]
2709 fn shl(self, rhs: &u16) -> Self {
2710 self.shl(*rhs)
2711 }
2712}
2713
2714impl Shl<&u16> for &I8Vec4 {
2715 type Output = I8Vec4;
2716 #[inline]
2717 fn shl(self, rhs: &u16) -> I8Vec4 {
2718 (*self).shl(*rhs)
2719 }
2720}
2721
2722impl Shl<u16> for &I8Vec4 {
2723 type Output = I8Vec4;
2724 #[inline]
2725 fn shl(self, rhs: u16) -> I8Vec4 {
2726 (*self).shl(rhs)
2727 }
2728}
2729
2730impl ShlAssign<u16> for I8Vec4 {
2731 #[inline]
2732 fn shl_assign(&mut self, rhs: u16) {
2733 *self = self.shl(rhs);
2734 }
2735}
2736
2737impl ShlAssign<&u16> for I8Vec4 {
2738 #[inline]
2739 fn shl_assign(&mut self, rhs: &u16) {
2740 self.shl_assign(*rhs);
2741 }
2742}
2743
2744impl Shr<u16> for I8Vec4 {
2745 type Output = Self;
2746 #[inline]
2747 fn shr(self, rhs: u16) -> Self::Output {
2748 Self {
2749 x: self.x.shr(rhs),
2750 y: self.y.shr(rhs),
2751 z: self.z.shr(rhs),
2752 w: self.w.shr(rhs),
2753 }
2754 }
2755}
2756
2757impl Shr<&u16> for I8Vec4 {
2758 type Output = Self;
2759 #[inline]
2760 fn shr(self, rhs: &u16) -> Self {
2761 self.shr(*rhs)
2762 }
2763}
2764
2765impl Shr<&u16> for &I8Vec4 {
2766 type Output = I8Vec4;
2767 #[inline]
2768 fn shr(self, rhs: &u16) -> I8Vec4 {
2769 (*self).shr(*rhs)
2770 }
2771}
2772
2773impl Shr<u16> for &I8Vec4 {
2774 type Output = I8Vec4;
2775 #[inline]
2776 fn shr(self, rhs: u16) -> I8Vec4 {
2777 (*self).shr(rhs)
2778 }
2779}
2780
2781impl ShrAssign<u16> for I8Vec4 {
2782 #[inline]
2783 fn shr_assign(&mut self, rhs: u16) {
2784 *self = self.shr(rhs);
2785 }
2786}
2787
2788impl ShrAssign<&u16> for I8Vec4 {
2789 #[inline]
2790 fn shr_assign(&mut self, rhs: &u16) {
2791 self.shr_assign(*rhs);
2792 }
2793}
2794
2795impl Shl<u32> for I8Vec4 {
2796 type Output = Self;
2797 #[inline]
2798 fn shl(self, rhs: u32) -> Self::Output {
2799 Self {
2800 x: self.x.shl(rhs),
2801 y: self.y.shl(rhs),
2802 z: self.z.shl(rhs),
2803 w: self.w.shl(rhs),
2804 }
2805 }
2806}
2807
2808impl Shl<&u32> for I8Vec4 {
2809 type Output = Self;
2810 #[inline]
2811 fn shl(self, rhs: &u32) -> Self {
2812 self.shl(*rhs)
2813 }
2814}
2815
2816impl Shl<&u32> for &I8Vec4 {
2817 type Output = I8Vec4;
2818 #[inline]
2819 fn shl(self, rhs: &u32) -> I8Vec4 {
2820 (*self).shl(*rhs)
2821 }
2822}
2823
2824impl Shl<u32> for &I8Vec4 {
2825 type Output = I8Vec4;
2826 #[inline]
2827 fn shl(self, rhs: u32) -> I8Vec4 {
2828 (*self).shl(rhs)
2829 }
2830}
2831
2832impl ShlAssign<u32> for I8Vec4 {
2833 #[inline]
2834 fn shl_assign(&mut self, rhs: u32) {
2835 *self = self.shl(rhs);
2836 }
2837}
2838
2839impl ShlAssign<&u32> for I8Vec4 {
2840 #[inline]
2841 fn shl_assign(&mut self, rhs: &u32) {
2842 self.shl_assign(*rhs);
2843 }
2844}
2845
2846impl Shr<u32> for I8Vec4 {
2847 type Output = Self;
2848 #[inline]
2849 fn shr(self, rhs: u32) -> Self::Output {
2850 Self {
2851 x: self.x.shr(rhs),
2852 y: self.y.shr(rhs),
2853 z: self.z.shr(rhs),
2854 w: self.w.shr(rhs),
2855 }
2856 }
2857}
2858
2859impl Shr<&u32> for I8Vec4 {
2860 type Output = Self;
2861 #[inline]
2862 fn shr(self, rhs: &u32) -> Self {
2863 self.shr(*rhs)
2864 }
2865}
2866
2867impl Shr<&u32> for &I8Vec4 {
2868 type Output = I8Vec4;
2869 #[inline]
2870 fn shr(self, rhs: &u32) -> I8Vec4 {
2871 (*self).shr(*rhs)
2872 }
2873}
2874
2875impl Shr<u32> for &I8Vec4 {
2876 type Output = I8Vec4;
2877 #[inline]
2878 fn shr(self, rhs: u32) -> I8Vec4 {
2879 (*self).shr(rhs)
2880 }
2881}
2882
2883impl ShrAssign<u32> for I8Vec4 {
2884 #[inline]
2885 fn shr_assign(&mut self, rhs: u32) {
2886 *self = self.shr(rhs);
2887 }
2888}
2889
2890impl ShrAssign<&u32> for I8Vec4 {
2891 #[inline]
2892 fn shr_assign(&mut self, rhs: &u32) {
2893 self.shr_assign(*rhs);
2894 }
2895}
2896
2897impl Shl<u64> for I8Vec4 {
2898 type Output = Self;
2899 #[inline]
2900 fn shl(self, rhs: u64) -> Self::Output {
2901 Self {
2902 x: self.x.shl(rhs),
2903 y: self.y.shl(rhs),
2904 z: self.z.shl(rhs),
2905 w: self.w.shl(rhs),
2906 }
2907 }
2908}
2909
2910impl Shl<&u64> for I8Vec4 {
2911 type Output = Self;
2912 #[inline]
2913 fn shl(self, rhs: &u64) -> Self {
2914 self.shl(*rhs)
2915 }
2916}
2917
2918impl Shl<&u64> for &I8Vec4 {
2919 type Output = I8Vec4;
2920 #[inline]
2921 fn shl(self, rhs: &u64) -> I8Vec4 {
2922 (*self).shl(*rhs)
2923 }
2924}
2925
2926impl Shl<u64> for &I8Vec4 {
2927 type Output = I8Vec4;
2928 #[inline]
2929 fn shl(self, rhs: u64) -> I8Vec4 {
2930 (*self).shl(rhs)
2931 }
2932}
2933
2934impl ShlAssign<u64> for I8Vec4 {
2935 #[inline]
2936 fn shl_assign(&mut self, rhs: u64) {
2937 *self = self.shl(rhs);
2938 }
2939}
2940
2941impl ShlAssign<&u64> for I8Vec4 {
2942 #[inline]
2943 fn shl_assign(&mut self, rhs: &u64) {
2944 self.shl_assign(*rhs);
2945 }
2946}
2947
2948impl Shr<u64> for I8Vec4 {
2949 type Output = Self;
2950 #[inline]
2951 fn shr(self, rhs: u64) -> Self::Output {
2952 Self {
2953 x: self.x.shr(rhs),
2954 y: self.y.shr(rhs),
2955 z: self.z.shr(rhs),
2956 w: self.w.shr(rhs),
2957 }
2958 }
2959}
2960
2961impl Shr<&u64> for I8Vec4 {
2962 type Output = Self;
2963 #[inline]
2964 fn shr(self, rhs: &u64) -> Self {
2965 self.shr(*rhs)
2966 }
2967}
2968
2969impl Shr<&u64> for &I8Vec4 {
2970 type Output = I8Vec4;
2971 #[inline]
2972 fn shr(self, rhs: &u64) -> I8Vec4 {
2973 (*self).shr(*rhs)
2974 }
2975}
2976
2977impl Shr<u64> for &I8Vec4 {
2978 type Output = I8Vec4;
2979 #[inline]
2980 fn shr(self, rhs: u64) -> I8Vec4 {
2981 (*self).shr(rhs)
2982 }
2983}
2984
2985impl ShrAssign<u64> for I8Vec4 {
2986 #[inline]
2987 fn shr_assign(&mut self, rhs: u64) {
2988 *self = self.shr(rhs);
2989 }
2990}
2991
2992impl ShrAssign<&u64> for I8Vec4 {
2993 #[inline]
2994 fn shr_assign(&mut self, rhs: &u64) {
2995 self.shr_assign(*rhs);
2996 }
2997}
2998
2999#[cfg(feature = "i32")]
3000impl Shl<IVec4> for I8Vec4 {
3001 type Output = Self;
3002 #[inline]
3003 fn shl(self, rhs: IVec4) -> Self {
3004 Self {
3005 x: self.x.shl(rhs.x),
3006 y: self.y.shl(rhs.y),
3007 z: self.z.shl(rhs.z),
3008 w: self.w.shl(rhs.w),
3009 }
3010 }
3011}
3012
3013#[cfg(feature = "i32")]
3014impl Shl<&IVec4> for I8Vec4 {
3015 type Output = Self;
3016 #[inline]
3017 fn shl(self, rhs: &IVec4) -> Self {
3018 self.shl(*rhs)
3019 }
3020}
3021
3022#[cfg(feature = "i32")]
3023impl Shl<&IVec4> for &I8Vec4 {
3024 type Output = I8Vec4;
3025 #[inline]
3026 fn shl(self, rhs: &IVec4) -> I8Vec4 {
3027 (*self).shl(*rhs)
3028 }
3029}
3030
3031#[cfg(feature = "i32")]
3032impl Shl<IVec4> for &I8Vec4 {
3033 type Output = I8Vec4;
3034 #[inline]
3035 fn shl(self, rhs: IVec4) -> I8Vec4 {
3036 (*self).shl(rhs)
3037 }
3038}
3039
3040#[cfg(feature = "i32")]
3041impl Shr<IVec4> for I8Vec4 {
3042 type Output = Self;
3043 #[inline]
3044 fn shr(self, rhs: IVec4) -> Self {
3045 Self {
3046 x: self.x.shr(rhs.x),
3047 y: self.y.shr(rhs.y),
3048 z: self.z.shr(rhs.z),
3049 w: self.w.shr(rhs.w),
3050 }
3051 }
3052}
3053
3054#[cfg(feature = "i32")]
3055impl Shr<&IVec4> for I8Vec4 {
3056 type Output = Self;
3057 #[inline]
3058 fn shr(self, rhs: &IVec4) -> Self {
3059 self.shr(*rhs)
3060 }
3061}
3062
3063#[cfg(feature = "i32")]
3064impl Shr<&IVec4> for &I8Vec4 {
3065 type Output = I8Vec4;
3066 #[inline]
3067 fn shr(self, rhs: &IVec4) -> I8Vec4 {
3068 (*self).shr(*rhs)
3069 }
3070}
3071
3072#[cfg(feature = "i32")]
3073impl Shr<IVec4> for &I8Vec4 {
3074 type Output = I8Vec4;
3075 #[inline]
3076 fn shr(self, rhs: IVec4) -> I8Vec4 {
3077 (*self).shr(rhs)
3078 }
3079}
3080
3081#[cfg(feature = "u32")]
3082impl Shl<UVec4> for I8Vec4 {
3083 type Output = Self;
3084 #[inline]
3085 fn shl(self, rhs: UVec4) -> Self {
3086 Self {
3087 x: self.x.shl(rhs.x),
3088 y: self.y.shl(rhs.y),
3089 z: self.z.shl(rhs.z),
3090 w: self.w.shl(rhs.w),
3091 }
3092 }
3093}
3094
3095#[cfg(feature = "u32")]
3096impl Shl<&UVec4> for I8Vec4 {
3097 type Output = Self;
3098 #[inline]
3099 fn shl(self, rhs: &UVec4) -> Self {
3100 self.shl(*rhs)
3101 }
3102}
3103
3104#[cfg(feature = "u32")]
3105impl Shl<&UVec4> for &I8Vec4 {
3106 type Output = I8Vec4;
3107 #[inline]
3108 fn shl(self, rhs: &UVec4) -> I8Vec4 {
3109 (*self).shl(*rhs)
3110 }
3111}
3112
3113#[cfg(feature = "u32")]
3114impl Shl<UVec4> for &I8Vec4 {
3115 type Output = I8Vec4;
3116 #[inline]
3117 fn shl(self, rhs: UVec4) -> I8Vec4 {
3118 (*self).shl(rhs)
3119 }
3120}
3121
3122#[cfg(feature = "u32")]
3123impl Shr<UVec4> for I8Vec4 {
3124 type Output = Self;
3125 #[inline]
3126 fn shr(self, rhs: UVec4) -> Self {
3127 Self {
3128 x: self.x.shr(rhs.x),
3129 y: self.y.shr(rhs.y),
3130 z: self.z.shr(rhs.z),
3131 w: self.w.shr(rhs.w),
3132 }
3133 }
3134}
3135
3136#[cfg(feature = "u32")]
3137impl Shr<&UVec4> for I8Vec4 {
3138 type Output = Self;
3139 #[inline]
3140 fn shr(self, rhs: &UVec4) -> Self {
3141 self.shr(*rhs)
3142 }
3143}
3144
3145#[cfg(feature = "u32")]
3146impl Shr<&UVec4> for &I8Vec4 {
3147 type Output = I8Vec4;
3148 #[inline]
3149 fn shr(self, rhs: &UVec4) -> I8Vec4 {
3150 (*self).shr(*rhs)
3151 }
3152}
3153
3154#[cfg(feature = "u32")]
3155impl Shr<UVec4> for &I8Vec4 {
3156 type Output = I8Vec4;
3157 #[inline]
3158 fn shr(self, rhs: UVec4) -> I8Vec4 {
3159 (*self).shr(rhs)
3160 }
3161}
3162
3163impl Index<usize> for I8Vec4 {
3164 type Output = i8;
3165 #[inline]
3166 fn index(&self, index: usize) -> &Self::Output {
3167 match index {
3168 0 => &self.x,
3169 1 => &self.y,
3170 2 => &self.z,
3171 3 => &self.w,
3172 _ => panic!("index out of bounds"),
3173 }
3174 }
3175}
3176
3177impl IndexMut<usize> for I8Vec4 {
3178 #[inline]
3179 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
3180 match index {
3181 0 => &mut self.x,
3182 1 => &mut self.y,
3183 2 => &mut self.z,
3184 3 => &mut self.w,
3185 _ => panic!("index out of bounds"),
3186 }
3187 }
3188}
3189
3190impl fmt::Display for I8Vec4 {
3191 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3192 write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
3193 }
3194}
3195
3196impl fmt::Debug for I8Vec4 {
3197 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
3198 fmt.debug_tuple(stringify!(I8Vec4))
3199 .field(&self.x)
3200 .field(&self.y)
3201 .field(&self.z)
3202 .field(&self.w)
3203 .finish()
3204 }
3205}
3206
3207impl From<[i8; 4]> for I8Vec4 {
3208 #[inline]
3209 fn from(a: [i8; 4]) -> Self {
3210 Self::new(a[0], a[1], a[2], a[3])
3211 }
3212}
3213
3214impl From<I8Vec4> for [i8; 4] {
3215 #[inline]
3216 fn from(v: I8Vec4) -> Self {
3217 [v.x, v.y, v.z, v.w]
3218 }
3219}
3220
3221impl From<(i8, i8, i8, i8)> for I8Vec4 {
3222 #[inline]
3223 fn from(t: (i8, i8, i8, i8)) -> Self {
3224 Self::new(t.0, t.1, t.2, t.3)
3225 }
3226}
3227
3228impl From<I8Vec4> for (i8, i8, i8, i8) {
3229 #[inline]
3230 fn from(v: I8Vec4) -> Self {
3231 (v.x, v.y, v.z, v.w)
3232 }
3233}
3234
3235impl From<(I8Vec3, i8)> for I8Vec4 {
3236 #[inline]
3237 fn from((v, w): (I8Vec3, i8)) -> Self {
3238 Self::new(v.x, v.y, v.z, w)
3239 }
3240}
3241
3242impl From<(i8, I8Vec3)> for I8Vec4 {
3243 #[inline]
3244 fn from((x, v): (i8, I8Vec3)) -> Self {
3245 Self::new(x, v.x, v.y, v.z)
3246 }
3247}
3248
3249impl From<(I8Vec2, i8, i8)> for I8Vec4 {
3250 #[inline]
3251 fn from((v, z, w): (I8Vec2, i8, i8)) -> Self {
3252 Self::new(v.x, v.y, z, w)
3253 }
3254}
3255
3256impl From<(I8Vec2, I8Vec2)> for I8Vec4 {
3257 #[inline]
3258 fn from((v, u): (I8Vec2, I8Vec2)) -> Self {
3259 Self::new(v.x, v.y, u.x, u.y)
3260 }
3261}
3262
3263#[cfg(feature = "u8")]
3264impl TryFrom<U8Vec4> for I8Vec4 {
3265 type Error = core::num::TryFromIntError;
3266
3267 #[inline]
3268 fn try_from(v: U8Vec4) -> Result<Self, Self::Error> {
3269 Ok(Self::new(
3270 i8::try_from(v.x)?,
3271 i8::try_from(v.y)?,
3272 i8::try_from(v.z)?,
3273 i8::try_from(v.w)?,
3274 ))
3275 }
3276}
3277
3278#[cfg(feature = "i16")]
3279impl TryFrom<I16Vec4> for I8Vec4 {
3280 type Error = core::num::TryFromIntError;
3281
3282 #[inline]
3283 fn try_from(v: I16Vec4) -> Result<Self, Self::Error> {
3284 Ok(Self::new(
3285 i8::try_from(v.x)?,
3286 i8::try_from(v.y)?,
3287 i8::try_from(v.z)?,
3288 i8::try_from(v.w)?,
3289 ))
3290 }
3291}
3292
3293#[cfg(feature = "u16")]
3294impl TryFrom<U16Vec4> for I8Vec4 {
3295 type Error = core::num::TryFromIntError;
3296
3297 #[inline]
3298 fn try_from(v: U16Vec4) -> Result<Self, Self::Error> {
3299 Ok(Self::new(
3300 i8::try_from(v.x)?,
3301 i8::try_from(v.y)?,
3302 i8::try_from(v.z)?,
3303 i8::try_from(v.w)?,
3304 ))
3305 }
3306}
3307
3308#[cfg(feature = "i32")]
3309impl TryFrom<IVec4> for I8Vec4 {
3310 type Error = core::num::TryFromIntError;
3311
3312 #[inline]
3313 fn try_from(v: IVec4) -> Result<Self, Self::Error> {
3314 Ok(Self::new(
3315 i8::try_from(v.x)?,
3316 i8::try_from(v.y)?,
3317 i8::try_from(v.z)?,
3318 i8::try_from(v.w)?,
3319 ))
3320 }
3321}
3322
3323#[cfg(feature = "u32")]
3324impl TryFrom<UVec4> for I8Vec4 {
3325 type Error = core::num::TryFromIntError;
3326
3327 #[inline]
3328 fn try_from(v: UVec4) -> Result<Self, Self::Error> {
3329 Ok(Self::new(
3330 i8::try_from(v.x)?,
3331 i8::try_from(v.y)?,
3332 i8::try_from(v.z)?,
3333 i8::try_from(v.w)?,
3334 ))
3335 }
3336}
3337
3338#[cfg(feature = "i64")]
3339impl TryFrom<I64Vec4> for I8Vec4 {
3340 type Error = core::num::TryFromIntError;
3341
3342 #[inline]
3343 fn try_from(v: I64Vec4) -> Result<Self, Self::Error> {
3344 Ok(Self::new(
3345 i8::try_from(v.x)?,
3346 i8::try_from(v.y)?,
3347 i8::try_from(v.z)?,
3348 i8::try_from(v.w)?,
3349 ))
3350 }
3351}
3352
3353#[cfg(feature = "u64")]
3354impl TryFrom<U64Vec4> for I8Vec4 {
3355 type Error = core::num::TryFromIntError;
3356
3357 #[inline]
3358 fn try_from(v: U64Vec4) -> Result<Self, Self::Error> {
3359 Ok(Self::new(
3360 i8::try_from(v.x)?,
3361 i8::try_from(v.y)?,
3362 i8::try_from(v.z)?,
3363 i8::try_from(v.w)?,
3364 ))
3365 }
3366}
3367
3368#[cfg(feature = "isize")]
3369impl TryFrom<ISizeVec4> for I8Vec4 {
3370 type Error = core::num::TryFromIntError;
3371
3372 #[inline]
3373 fn try_from(v: ISizeVec4) -> Result<Self, Self::Error> {
3374 Ok(Self::new(
3375 i8::try_from(v.x)?,
3376 i8::try_from(v.y)?,
3377 i8::try_from(v.z)?,
3378 i8::try_from(v.w)?,
3379 ))
3380 }
3381}
3382
3383#[cfg(feature = "usize")]
3384impl TryFrom<USizeVec4> for I8Vec4 {
3385 type Error = core::num::TryFromIntError;
3386
3387 #[inline]
3388 fn try_from(v: USizeVec4) -> Result<Self, Self::Error> {
3389 Ok(Self::new(
3390 i8::try_from(v.x)?,
3391 i8::try_from(v.y)?,
3392 i8::try_from(v.z)?,
3393 i8::try_from(v.w)?,
3394 ))
3395 }
3396}
3397
3398impl From<BVec4> for I8Vec4 {
3399 #[inline]
3400 fn from(v: BVec4) -> Self {
3401 Self::new(i8::from(v.x), i8::from(v.y), i8::from(v.z), i8::from(v.w))
3402 }
3403}
3404
3405#[cfg(not(feature = "scalar-math"))]
3406impl From<BVec4A> for I8Vec4 {
3407 #[inline]
3408 fn from(v: BVec4A) -> Self {
3409 let bool_array: [bool; 4] = v.into();
3410 Self::new(
3411 i8::from(bool_array[0]),
3412 i8::from(bool_array[1]),
3413 i8::from(bool_array[2]),
3414 i8::from(bool_array[3]),
3415 )
3416 }
3417}