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