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