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