1use crate::{
4 BVec3, BVec3A, I16Vec3, I64Vec3, I8Vec3, IVec3, U16Vec3, U64Vec3, U8Vec3, USizeVec2, USizeVec4,
5 UVec3,
6};
7
8use core::fmt;
9use core::iter::{Product, Sum};
10use core::{f32, ops::*};
11
12#[inline(always)]
14#[must_use]
15pub const fn usizevec3(x: usize, y: usize, z: usize) -> USizeVec3 {
16 USizeVec3::new(x, y, z)
17}
18
19#[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
21#[derive(Clone, Copy, PartialEq, Eq)]
22#[cfg_attr(not(target_arch = "spirv"), repr(C))]
23#[cfg_attr(target_arch = "spirv", repr(simd))]
24pub struct USizeVec3 {
25 pub x: usize,
26 pub y: usize,
27 pub z: usize,
28}
29
30impl USizeVec3 {
31 pub const ZERO: Self = Self::splat(0);
33
34 pub const ONE: Self = Self::splat(1);
36
37 pub const MIN: Self = Self::splat(usize::MIN);
39
40 pub const MAX: Self = Self::splat(usize::MAX);
42
43 pub const X: Self = Self::new(1, 0, 0);
45
46 pub const Y: Self = Self::new(0, 1, 0);
48
49 pub const Z: Self = Self::new(0, 0, 1);
51
52 pub const AXES: [Self; 3] = [Self::X, Self::Y, Self::Z];
54
55 #[inline(always)]
57 #[must_use]
58 pub const fn new(x: usize, y: usize, z: usize) -> Self {
59 Self { x, y, z }
60 }
61
62 #[inline]
64 #[must_use]
65 pub const fn splat(v: usize) -> Self {
66 Self { x: v, y: v, z: v }
67 }
68
69 #[inline]
71 #[must_use]
72 pub fn map<F>(self, f: F) -> Self
73 where
74 F: Fn(usize) -> usize,
75 {
76 Self::new(f(self.x), f(self.y), f(self.z))
77 }
78
79 #[inline]
85 #[must_use]
86 pub fn select(mask: BVec3, if_true: Self, if_false: Self) -> Self {
87 Self {
88 x: if mask.test(0) { if_true.x } else { if_false.x },
89 y: if mask.test(1) { if_true.y } else { if_false.y },
90 z: if mask.test(2) { if_true.z } else { if_false.z },
91 }
92 }
93
94 #[inline]
96 #[must_use]
97 pub const fn from_array(a: [usize; 3]) -> Self {
98 Self::new(a[0], a[1], a[2])
99 }
100
101 #[inline]
103 #[must_use]
104 pub const fn to_array(&self) -> [usize; 3] {
105 [self.x, self.y, self.z]
106 }
107
108 #[inline]
114 #[must_use]
115 pub const fn from_slice(slice: &[usize]) -> Self {
116 assert!(slice.len() >= 3);
117 Self::new(slice[0], slice[1], slice[2])
118 }
119
120 #[inline]
126 pub fn write_to_slice(self, slice: &mut [usize]) {
127 slice[..3].copy_from_slice(&self.to_array());
128 }
129
130 #[allow(dead_code)]
132 #[inline]
133 #[must_use]
134 pub(crate) fn from_vec4(v: USizeVec4) -> Self {
135 Self {
136 x: v.x,
137 y: v.y,
138 z: v.z,
139 }
140 }
141
142 #[inline]
144 #[must_use]
145 pub fn extend(self, w: usize) -> USizeVec4 {
146 USizeVec4::new(self.x, self.y, self.z, w)
147 }
148
149 #[inline]
153 #[must_use]
154 pub fn truncate(self) -> USizeVec2 {
155 use crate::swizzles::Vec3Swizzles;
156 self.xy()
157 }
158
159 #[inline]
161 #[must_use]
162 pub fn with_x(mut self, x: usize) -> Self {
163 self.x = x;
164 self
165 }
166
167 #[inline]
169 #[must_use]
170 pub fn with_y(mut self, y: usize) -> Self {
171 self.y = y;
172 self
173 }
174
175 #[inline]
177 #[must_use]
178 pub fn with_z(mut self, z: usize) -> Self {
179 self.z = z;
180 self
181 }
182
183 #[inline]
185 #[must_use]
186 pub fn dot(self, rhs: Self) -> usize {
187 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
188 }
189
190 #[inline]
192 #[must_use]
193 pub fn dot_into_vec(self, rhs: Self) -> Self {
194 Self::splat(self.dot(rhs))
195 }
196
197 #[inline]
199 #[must_use]
200 pub fn cross(self, rhs: Self) -> Self {
201 Self {
202 x: self.y * rhs.z - rhs.y * self.z,
203 y: self.z * rhs.x - rhs.z * self.x,
204 z: self.x * rhs.y - rhs.x * self.y,
205 }
206 }
207
208 #[inline]
212 #[must_use]
213 pub fn min(self, rhs: Self) -> Self {
214 Self {
215 x: if self.x < rhs.x { self.x } else { rhs.x },
216 y: if self.y < rhs.y { self.y } else { rhs.y },
217 z: if self.z < rhs.z { self.z } else { rhs.z },
218 }
219 }
220
221 #[inline]
225 #[must_use]
226 pub fn max(self, rhs: Self) -> Self {
227 Self {
228 x: if self.x > rhs.x { self.x } else { rhs.x },
229 y: if self.y > rhs.y { self.y } else { rhs.y },
230 z: if self.z > rhs.z { self.z } else { rhs.z },
231 }
232 }
233
234 #[inline]
242 #[must_use]
243 pub fn clamp(self, min: Self, max: Self) -> Self {
244 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
245 self.max(min).min(max)
246 }
247
248 #[inline]
252 #[must_use]
253 pub fn min_element(self) -> usize {
254 let min = |a, b| if a < b { a } else { b };
255 min(self.x, min(self.y, self.z))
256 }
257
258 #[inline]
262 #[must_use]
263 pub fn max_element(self) -> usize {
264 let max = |a, b| if a > b { a } else { b };
265 max(self.x, max(self.y, self.z))
266 }
267
268 #[doc(alias = "argmin")]
270 #[inline]
271 #[must_use]
272 pub fn min_position(self) -> usize {
273 let mut min = self.x;
274 let mut index = 0;
275 if self.y < min {
276 min = self.y;
277 index = 1;
278 }
279 if self.z < min {
280 index = 2;
281 }
282 index
283 }
284
285 #[doc(alias = "argmax")]
287 #[inline]
288 #[must_use]
289 pub fn max_position(self) -> usize {
290 let mut max = self.x;
291 let mut index = 0;
292 if self.y > max {
293 max = self.y;
294 index = 1;
295 }
296 if self.z > max {
297 index = 2;
298 }
299 index
300 }
301
302 #[inline]
306 #[must_use]
307 pub fn element_sum(self) -> usize {
308 self.x + self.y + self.z
309 }
310
311 #[inline]
315 #[must_use]
316 pub fn element_product(self) -> usize {
317 self.x * self.y * self.z
318 }
319
320 #[inline]
326 #[must_use]
327 pub fn cmpeq(self, rhs: Self) -> BVec3 {
328 BVec3::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y), self.z.eq(&rhs.z))
329 }
330
331 #[inline]
337 #[must_use]
338 pub fn cmpne(self, rhs: Self) -> BVec3 {
339 BVec3::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y), self.z.ne(&rhs.z))
340 }
341
342 #[inline]
348 #[must_use]
349 pub fn cmpge(self, rhs: Self) -> BVec3 {
350 BVec3::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y), self.z.ge(&rhs.z))
351 }
352
353 #[inline]
359 #[must_use]
360 pub fn cmpgt(self, rhs: Self) -> BVec3 {
361 BVec3::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y), self.z.gt(&rhs.z))
362 }
363
364 #[inline]
370 #[must_use]
371 pub fn cmple(self, rhs: Self) -> BVec3 {
372 BVec3::new(self.x.le(&rhs.x), self.y.le(&rhs.y), self.z.le(&rhs.z))
373 }
374
375 #[inline]
381 #[must_use]
382 pub fn cmplt(self, rhs: Self) -> BVec3 {
383 BVec3::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y), self.z.lt(&rhs.z))
384 }
385
386 #[doc(alias = "magnitude2")]
388 #[inline]
389 #[must_use]
390 pub fn length_squared(self) -> usize {
391 self.dot(self)
392 }
393
394 #[inline]
403 #[must_use]
404 pub fn manhattan_distance(self, other: Self) -> usize {
405 self.x.abs_diff(other.x) + self.y.abs_diff(other.y) + self.z.abs_diff(other.z)
406 }
407
408 #[inline]
414 #[must_use]
415 pub fn checked_manhattan_distance(self, other: Self) -> Option<usize> {
416 let d = self.x.abs_diff(other.x);
417 let d = d.checked_add(self.y.abs_diff(other.y))?;
418 d.checked_add(self.z.abs_diff(other.z))
419 }
420
421 #[inline]
425 #[must_use]
426 pub fn chebyshev_distance(self, other: Self) -> usize {
427 [
429 self.x.abs_diff(other.x),
430 self.y.abs_diff(other.y),
431 self.z.abs_diff(other.z),
432 ]
433 .into_iter()
434 .max()
435 .unwrap()
436 }
437
438 #[inline]
440 #[must_use]
441 pub fn as_vec3(&self) -> crate::Vec3 {
442 crate::Vec3::new(self.x as f32, self.y as f32, self.z as f32)
443 }
444
445 #[inline]
447 #[must_use]
448 pub fn as_vec3a(&self) -> crate::Vec3A {
449 crate::Vec3A::new(self.x as f32, self.y as f32, self.z as f32)
450 }
451
452 #[inline]
454 #[must_use]
455 pub fn as_dvec3(&self) -> crate::DVec3 {
456 crate::DVec3::new(self.x as f64, self.y as f64, self.z as f64)
457 }
458
459 #[inline]
461 #[must_use]
462 pub fn as_i8vec3(&self) -> crate::I8Vec3 {
463 crate::I8Vec3::new(self.x as i8, self.y as i8, self.z as i8)
464 }
465
466 #[inline]
468 #[must_use]
469 pub fn as_u8vec3(&self) -> crate::U8Vec3 {
470 crate::U8Vec3::new(self.x as u8, self.y as u8, self.z as u8)
471 }
472
473 #[inline]
475 #[must_use]
476 pub fn as_i16vec3(&self) -> crate::I16Vec3 {
477 crate::I16Vec3::new(self.x as i16, self.y as i16, self.z as i16)
478 }
479
480 #[inline]
482 #[must_use]
483 pub fn as_u16vec3(&self) -> crate::U16Vec3 {
484 crate::U16Vec3::new(self.x as u16, self.y as u16, self.z as u16)
485 }
486
487 #[inline]
489 #[must_use]
490 pub fn as_ivec3(&self) -> crate::IVec3 {
491 crate::IVec3::new(self.x as i32, self.y as i32, self.z as i32)
492 }
493
494 #[inline]
496 #[must_use]
497 pub fn as_uvec3(&self) -> crate::UVec3 {
498 crate::UVec3::new(self.x as u32, self.y as u32, self.z as u32)
499 }
500
501 #[inline]
503 #[must_use]
504 pub fn as_i64vec3(&self) -> crate::I64Vec3 {
505 crate::I64Vec3::new(self.x as i64, self.y as i64, self.z as i64)
506 }
507
508 #[inline]
510 #[must_use]
511 pub fn as_u64vec3(&self) -> crate::U64Vec3 {
512 crate::U64Vec3::new(self.x as u64, self.y as u64, self.z as u64)
513 }
514
515 #[inline]
519 #[must_use]
520 pub const fn checked_add(self, rhs: Self) -> Option<Self> {
521 let x = match self.x.checked_add(rhs.x) {
522 Some(v) => v,
523 None => return None,
524 };
525 let y = match self.y.checked_add(rhs.y) {
526 Some(v) => v,
527 None => return None,
528 };
529 let z = match self.z.checked_add(rhs.z) {
530 Some(v) => v,
531 None => return None,
532 };
533
534 Some(Self { x, y, z })
535 }
536
537 #[inline]
541 #[must_use]
542 pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
543 let x = match self.x.checked_sub(rhs.x) {
544 Some(v) => v,
545 None => return None,
546 };
547 let y = match self.y.checked_sub(rhs.y) {
548 Some(v) => v,
549 None => return None,
550 };
551 let z = match self.z.checked_sub(rhs.z) {
552 Some(v) => v,
553 None => return None,
554 };
555
556 Some(Self { x, y, z })
557 }
558
559 #[inline]
563 #[must_use]
564 pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
565 let x = match self.x.checked_mul(rhs.x) {
566 Some(v) => v,
567 None => return None,
568 };
569 let y = match self.y.checked_mul(rhs.y) {
570 Some(v) => v,
571 None => return None,
572 };
573 let z = match self.z.checked_mul(rhs.z) {
574 Some(v) => v,
575 None => return None,
576 };
577
578 Some(Self { x, y, z })
579 }
580
581 #[inline]
585 #[must_use]
586 pub const fn checked_div(self, rhs: Self) -> Option<Self> {
587 let x = match self.x.checked_div(rhs.x) {
588 Some(v) => v,
589 None => return None,
590 };
591 let y = match self.y.checked_div(rhs.y) {
592 Some(v) => v,
593 None => return None,
594 };
595 let z = match self.z.checked_div(rhs.z) {
596 Some(v) => v,
597 None => return None,
598 };
599
600 Some(Self { x, y, z })
601 }
602
603 #[inline]
607 #[must_use]
608 pub const fn wrapping_add(self, rhs: Self) -> Self {
609 Self {
610 x: self.x.wrapping_add(rhs.x),
611 y: self.y.wrapping_add(rhs.y),
612 z: self.z.wrapping_add(rhs.z),
613 }
614 }
615
616 #[inline]
620 #[must_use]
621 pub const fn wrapping_sub(self, rhs: Self) -> Self {
622 Self {
623 x: self.x.wrapping_sub(rhs.x),
624 y: self.y.wrapping_sub(rhs.y),
625 z: self.z.wrapping_sub(rhs.z),
626 }
627 }
628
629 #[inline]
633 #[must_use]
634 pub const fn wrapping_mul(self, rhs: Self) -> Self {
635 Self {
636 x: self.x.wrapping_mul(rhs.x),
637 y: self.y.wrapping_mul(rhs.y),
638 z: self.z.wrapping_mul(rhs.z),
639 }
640 }
641
642 #[inline]
646 #[must_use]
647 pub const fn wrapping_div(self, rhs: Self) -> Self {
648 Self {
649 x: self.x.wrapping_div(rhs.x),
650 y: self.y.wrapping_div(rhs.y),
651 z: self.z.wrapping_div(rhs.z),
652 }
653 }
654
655 #[inline]
659 #[must_use]
660 pub const fn saturating_add(self, rhs: Self) -> Self {
661 Self {
662 x: self.x.saturating_add(rhs.x),
663 y: self.y.saturating_add(rhs.y),
664 z: self.z.saturating_add(rhs.z),
665 }
666 }
667
668 #[inline]
672 #[must_use]
673 pub const fn saturating_sub(self, rhs: Self) -> Self {
674 Self {
675 x: self.x.saturating_sub(rhs.x),
676 y: self.y.saturating_sub(rhs.y),
677 z: self.z.saturating_sub(rhs.z),
678 }
679 }
680
681 #[inline]
685 #[must_use]
686 pub const fn saturating_mul(self, rhs: Self) -> Self {
687 Self {
688 x: self.x.saturating_mul(rhs.x),
689 y: self.y.saturating_mul(rhs.y),
690 z: self.z.saturating_mul(rhs.z),
691 }
692 }
693
694 #[inline]
698 #[must_use]
699 pub const fn saturating_div(self, rhs: Self) -> Self {
700 Self {
701 x: self.x.saturating_div(rhs.x),
702 y: self.y.saturating_div(rhs.y),
703 z: self.z.saturating_div(rhs.z),
704 }
705 }
706}
707
708impl Default for USizeVec3 {
709 #[inline(always)]
710 fn default() -> Self {
711 Self::ZERO
712 }
713}
714
715impl Div<USizeVec3> for USizeVec3 {
716 type Output = Self;
717 #[inline]
718 fn div(self, rhs: Self) -> Self {
719 Self {
720 x: self.x.div(rhs.x),
721 y: self.y.div(rhs.y),
722 z: self.z.div(rhs.z),
723 }
724 }
725}
726
727impl Div<&USizeVec3> for USizeVec3 {
728 type Output = USizeVec3;
729 #[inline]
730 fn div(self, rhs: &USizeVec3) -> USizeVec3 {
731 self.div(*rhs)
732 }
733}
734
735impl Div<&USizeVec3> for &USizeVec3 {
736 type Output = USizeVec3;
737 #[inline]
738 fn div(self, rhs: &USizeVec3) -> USizeVec3 {
739 (*self).div(*rhs)
740 }
741}
742
743impl Div<USizeVec3> for &USizeVec3 {
744 type Output = USizeVec3;
745 #[inline]
746 fn div(self, rhs: USizeVec3) -> USizeVec3 {
747 (*self).div(rhs)
748 }
749}
750
751impl DivAssign<USizeVec3> for USizeVec3 {
752 #[inline]
753 fn div_assign(&mut self, rhs: Self) {
754 self.x.div_assign(rhs.x);
755 self.y.div_assign(rhs.y);
756 self.z.div_assign(rhs.z);
757 }
758}
759
760impl DivAssign<&USizeVec3> for USizeVec3 {
761 #[inline]
762 fn div_assign(&mut self, rhs: &USizeVec3) {
763 self.div_assign(*rhs)
764 }
765}
766
767impl Div<usize> for USizeVec3 {
768 type Output = Self;
769 #[inline]
770 fn div(self, rhs: usize) -> Self {
771 Self {
772 x: self.x.div(rhs),
773 y: self.y.div(rhs),
774 z: self.z.div(rhs),
775 }
776 }
777}
778
779impl Div<&usize> for USizeVec3 {
780 type Output = USizeVec3;
781 #[inline]
782 fn div(self, rhs: &usize) -> USizeVec3 {
783 self.div(*rhs)
784 }
785}
786
787impl Div<&usize> for &USizeVec3 {
788 type Output = USizeVec3;
789 #[inline]
790 fn div(self, rhs: &usize) -> USizeVec3 {
791 (*self).div(*rhs)
792 }
793}
794
795impl Div<usize> for &USizeVec3 {
796 type Output = USizeVec3;
797 #[inline]
798 fn div(self, rhs: usize) -> USizeVec3 {
799 (*self).div(rhs)
800 }
801}
802
803impl DivAssign<usize> for USizeVec3 {
804 #[inline]
805 fn div_assign(&mut self, rhs: usize) {
806 self.x.div_assign(rhs);
807 self.y.div_assign(rhs);
808 self.z.div_assign(rhs);
809 }
810}
811
812impl DivAssign<&usize> for USizeVec3 {
813 #[inline]
814 fn div_assign(&mut self, rhs: &usize) {
815 self.div_assign(*rhs)
816 }
817}
818
819impl Div<USizeVec3> for usize {
820 type Output = USizeVec3;
821 #[inline]
822 fn div(self, rhs: USizeVec3) -> USizeVec3 {
823 USizeVec3 {
824 x: self.div(rhs.x),
825 y: self.div(rhs.y),
826 z: self.div(rhs.z),
827 }
828 }
829}
830
831impl Div<&USizeVec3> for usize {
832 type Output = USizeVec3;
833 #[inline]
834 fn div(self, rhs: &USizeVec3) -> USizeVec3 {
835 self.div(*rhs)
836 }
837}
838
839impl Div<&USizeVec3> for &usize {
840 type Output = USizeVec3;
841 #[inline]
842 fn div(self, rhs: &USizeVec3) -> USizeVec3 {
843 (*self).div(*rhs)
844 }
845}
846
847impl Div<USizeVec3> for &usize {
848 type Output = USizeVec3;
849 #[inline]
850 fn div(self, rhs: USizeVec3) -> USizeVec3 {
851 (*self).div(rhs)
852 }
853}
854
855impl Mul<USizeVec3> for USizeVec3 {
856 type Output = Self;
857 #[inline]
858 fn mul(self, rhs: Self) -> Self {
859 Self {
860 x: self.x.mul(rhs.x),
861 y: self.y.mul(rhs.y),
862 z: self.z.mul(rhs.z),
863 }
864 }
865}
866
867impl Mul<&USizeVec3> for USizeVec3 {
868 type Output = USizeVec3;
869 #[inline]
870 fn mul(self, rhs: &USizeVec3) -> USizeVec3 {
871 self.mul(*rhs)
872 }
873}
874
875impl Mul<&USizeVec3> for &USizeVec3 {
876 type Output = USizeVec3;
877 #[inline]
878 fn mul(self, rhs: &USizeVec3) -> USizeVec3 {
879 (*self).mul(*rhs)
880 }
881}
882
883impl Mul<USizeVec3> for &USizeVec3 {
884 type Output = USizeVec3;
885 #[inline]
886 fn mul(self, rhs: USizeVec3) -> USizeVec3 {
887 (*self).mul(rhs)
888 }
889}
890
891impl MulAssign<USizeVec3> for USizeVec3 {
892 #[inline]
893 fn mul_assign(&mut self, rhs: Self) {
894 self.x.mul_assign(rhs.x);
895 self.y.mul_assign(rhs.y);
896 self.z.mul_assign(rhs.z);
897 }
898}
899
900impl MulAssign<&USizeVec3> for USizeVec3 {
901 #[inline]
902 fn mul_assign(&mut self, rhs: &USizeVec3) {
903 self.mul_assign(*rhs)
904 }
905}
906
907impl Mul<usize> for USizeVec3 {
908 type Output = Self;
909 #[inline]
910 fn mul(self, rhs: usize) -> Self {
911 Self {
912 x: self.x.mul(rhs),
913 y: self.y.mul(rhs),
914 z: self.z.mul(rhs),
915 }
916 }
917}
918
919impl Mul<&usize> for USizeVec3 {
920 type Output = USizeVec3;
921 #[inline]
922 fn mul(self, rhs: &usize) -> USizeVec3 {
923 self.mul(*rhs)
924 }
925}
926
927impl Mul<&usize> for &USizeVec3 {
928 type Output = USizeVec3;
929 #[inline]
930 fn mul(self, rhs: &usize) -> USizeVec3 {
931 (*self).mul(*rhs)
932 }
933}
934
935impl Mul<usize> for &USizeVec3 {
936 type Output = USizeVec3;
937 #[inline]
938 fn mul(self, rhs: usize) -> USizeVec3 {
939 (*self).mul(rhs)
940 }
941}
942
943impl MulAssign<usize> for USizeVec3 {
944 #[inline]
945 fn mul_assign(&mut self, rhs: usize) {
946 self.x.mul_assign(rhs);
947 self.y.mul_assign(rhs);
948 self.z.mul_assign(rhs);
949 }
950}
951
952impl MulAssign<&usize> for USizeVec3 {
953 #[inline]
954 fn mul_assign(&mut self, rhs: &usize) {
955 self.mul_assign(*rhs)
956 }
957}
958
959impl Mul<USizeVec3> for usize {
960 type Output = USizeVec3;
961 #[inline]
962 fn mul(self, rhs: USizeVec3) -> USizeVec3 {
963 USizeVec3 {
964 x: self.mul(rhs.x),
965 y: self.mul(rhs.y),
966 z: self.mul(rhs.z),
967 }
968 }
969}
970
971impl Mul<&USizeVec3> for usize {
972 type Output = USizeVec3;
973 #[inline]
974 fn mul(self, rhs: &USizeVec3) -> USizeVec3 {
975 self.mul(*rhs)
976 }
977}
978
979impl Mul<&USizeVec3> for &usize {
980 type Output = USizeVec3;
981 #[inline]
982 fn mul(self, rhs: &USizeVec3) -> USizeVec3 {
983 (*self).mul(*rhs)
984 }
985}
986
987impl Mul<USizeVec3> for &usize {
988 type Output = USizeVec3;
989 #[inline]
990 fn mul(self, rhs: USizeVec3) -> USizeVec3 {
991 (*self).mul(rhs)
992 }
993}
994
995impl Add<USizeVec3> for USizeVec3 {
996 type Output = Self;
997 #[inline]
998 fn add(self, rhs: Self) -> Self {
999 Self {
1000 x: self.x.add(rhs.x),
1001 y: self.y.add(rhs.y),
1002 z: self.z.add(rhs.z),
1003 }
1004 }
1005}
1006
1007impl Add<&USizeVec3> for USizeVec3 {
1008 type Output = USizeVec3;
1009 #[inline]
1010 fn add(self, rhs: &USizeVec3) -> USizeVec3 {
1011 self.add(*rhs)
1012 }
1013}
1014
1015impl Add<&USizeVec3> for &USizeVec3 {
1016 type Output = USizeVec3;
1017 #[inline]
1018 fn add(self, rhs: &USizeVec3) -> USizeVec3 {
1019 (*self).add(*rhs)
1020 }
1021}
1022
1023impl Add<USizeVec3> for &USizeVec3 {
1024 type Output = USizeVec3;
1025 #[inline]
1026 fn add(self, rhs: USizeVec3) -> USizeVec3 {
1027 (*self).add(rhs)
1028 }
1029}
1030
1031impl AddAssign<USizeVec3> for USizeVec3 {
1032 #[inline]
1033 fn add_assign(&mut self, rhs: Self) {
1034 self.x.add_assign(rhs.x);
1035 self.y.add_assign(rhs.y);
1036 self.z.add_assign(rhs.z);
1037 }
1038}
1039
1040impl AddAssign<&USizeVec3> for USizeVec3 {
1041 #[inline]
1042 fn add_assign(&mut self, rhs: &USizeVec3) {
1043 self.add_assign(*rhs)
1044 }
1045}
1046
1047impl Add<usize> for USizeVec3 {
1048 type Output = Self;
1049 #[inline]
1050 fn add(self, rhs: usize) -> Self {
1051 Self {
1052 x: self.x.add(rhs),
1053 y: self.y.add(rhs),
1054 z: self.z.add(rhs),
1055 }
1056 }
1057}
1058
1059impl Add<&usize> for USizeVec3 {
1060 type Output = USizeVec3;
1061 #[inline]
1062 fn add(self, rhs: &usize) -> USizeVec3 {
1063 self.add(*rhs)
1064 }
1065}
1066
1067impl Add<&usize> for &USizeVec3 {
1068 type Output = USizeVec3;
1069 #[inline]
1070 fn add(self, rhs: &usize) -> USizeVec3 {
1071 (*self).add(*rhs)
1072 }
1073}
1074
1075impl Add<usize> for &USizeVec3 {
1076 type Output = USizeVec3;
1077 #[inline]
1078 fn add(self, rhs: usize) -> USizeVec3 {
1079 (*self).add(rhs)
1080 }
1081}
1082
1083impl AddAssign<usize> for USizeVec3 {
1084 #[inline]
1085 fn add_assign(&mut self, rhs: usize) {
1086 self.x.add_assign(rhs);
1087 self.y.add_assign(rhs);
1088 self.z.add_assign(rhs);
1089 }
1090}
1091
1092impl AddAssign<&usize> for USizeVec3 {
1093 #[inline]
1094 fn add_assign(&mut self, rhs: &usize) {
1095 self.add_assign(*rhs)
1096 }
1097}
1098
1099impl Add<USizeVec3> for usize {
1100 type Output = USizeVec3;
1101 #[inline]
1102 fn add(self, rhs: USizeVec3) -> USizeVec3 {
1103 USizeVec3 {
1104 x: self.add(rhs.x),
1105 y: self.add(rhs.y),
1106 z: self.add(rhs.z),
1107 }
1108 }
1109}
1110
1111impl Add<&USizeVec3> for usize {
1112 type Output = USizeVec3;
1113 #[inline]
1114 fn add(self, rhs: &USizeVec3) -> USizeVec3 {
1115 self.add(*rhs)
1116 }
1117}
1118
1119impl Add<&USizeVec3> for &usize {
1120 type Output = USizeVec3;
1121 #[inline]
1122 fn add(self, rhs: &USizeVec3) -> USizeVec3 {
1123 (*self).add(*rhs)
1124 }
1125}
1126
1127impl Add<USizeVec3> for &usize {
1128 type Output = USizeVec3;
1129 #[inline]
1130 fn add(self, rhs: USizeVec3) -> USizeVec3 {
1131 (*self).add(rhs)
1132 }
1133}
1134
1135impl Sub<USizeVec3> for USizeVec3 {
1136 type Output = Self;
1137 #[inline]
1138 fn sub(self, rhs: Self) -> Self {
1139 Self {
1140 x: self.x.sub(rhs.x),
1141 y: self.y.sub(rhs.y),
1142 z: self.z.sub(rhs.z),
1143 }
1144 }
1145}
1146
1147impl Sub<&USizeVec3> for USizeVec3 {
1148 type Output = USizeVec3;
1149 #[inline]
1150 fn sub(self, rhs: &USizeVec3) -> USizeVec3 {
1151 self.sub(*rhs)
1152 }
1153}
1154
1155impl Sub<&USizeVec3> for &USizeVec3 {
1156 type Output = USizeVec3;
1157 #[inline]
1158 fn sub(self, rhs: &USizeVec3) -> USizeVec3 {
1159 (*self).sub(*rhs)
1160 }
1161}
1162
1163impl Sub<USizeVec3> for &USizeVec3 {
1164 type Output = USizeVec3;
1165 #[inline]
1166 fn sub(self, rhs: USizeVec3) -> USizeVec3 {
1167 (*self).sub(rhs)
1168 }
1169}
1170
1171impl SubAssign<USizeVec3> for USizeVec3 {
1172 #[inline]
1173 fn sub_assign(&mut self, rhs: USizeVec3) {
1174 self.x.sub_assign(rhs.x);
1175 self.y.sub_assign(rhs.y);
1176 self.z.sub_assign(rhs.z);
1177 }
1178}
1179
1180impl SubAssign<&USizeVec3> for USizeVec3 {
1181 #[inline]
1182 fn sub_assign(&mut self, rhs: &USizeVec3) {
1183 self.sub_assign(*rhs)
1184 }
1185}
1186
1187impl Sub<usize> for USizeVec3 {
1188 type Output = Self;
1189 #[inline]
1190 fn sub(self, rhs: usize) -> Self {
1191 Self {
1192 x: self.x.sub(rhs),
1193 y: self.y.sub(rhs),
1194 z: self.z.sub(rhs),
1195 }
1196 }
1197}
1198
1199impl Sub<&usize> for USizeVec3 {
1200 type Output = USizeVec3;
1201 #[inline]
1202 fn sub(self, rhs: &usize) -> USizeVec3 {
1203 self.sub(*rhs)
1204 }
1205}
1206
1207impl Sub<&usize> for &USizeVec3 {
1208 type Output = USizeVec3;
1209 #[inline]
1210 fn sub(self, rhs: &usize) -> USizeVec3 {
1211 (*self).sub(*rhs)
1212 }
1213}
1214
1215impl Sub<usize> for &USizeVec3 {
1216 type Output = USizeVec3;
1217 #[inline]
1218 fn sub(self, rhs: usize) -> USizeVec3 {
1219 (*self).sub(rhs)
1220 }
1221}
1222
1223impl SubAssign<usize> for USizeVec3 {
1224 #[inline]
1225 fn sub_assign(&mut self, rhs: usize) {
1226 self.x.sub_assign(rhs);
1227 self.y.sub_assign(rhs);
1228 self.z.sub_assign(rhs);
1229 }
1230}
1231
1232impl SubAssign<&usize> for USizeVec3 {
1233 #[inline]
1234 fn sub_assign(&mut self, rhs: &usize) {
1235 self.sub_assign(*rhs)
1236 }
1237}
1238
1239impl Sub<USizeVec3> for usize {
1240 type Output = USizeVec3;
1241 #[inline]
1242 fn sub(self, rhs: USizeVec3) -> USizeVec3 {
1243 USizeVec3 {
1244 x: self.sub(rhs.x),
1245 y: self.sub(rhs.y),
1246 z: self.sub(rhs.z),
1247 }
1248 }
1249}
1250
1251impl Sub<&USizeVec3> for usize {
1252 type Output = USizeVec3;
1253 #[inline]
1254 fn sub(self, rhs: &USizeVec3) -> USizeVec3 {
1255 self.sub(*rhs)
1256 }
1257}
1258
1259impl Sub<&USizeVec3> for &usize {
1260 type Output = USizeVec3;
1261 #[inline]
1262 fn sub(self, rhs: &USizeVec3) -> USizeVec3 {
1263 (*self).sub(*rhs)
1264 }
1265}
1266
1267impl Sub<USizeVec3> for &usize {
1268 type Output = USizeVec3;
1269 #[inline]
1270 fn sub(self, rhs: USizeVec3) -> USizeVec3 {
1271 (*self).sub(rhs)
1272 }
1273}
1274
1275impl Rem<USizeVec3> for USizeVec3 {
1276 type Output = Self;
1277 #[inline]
1278 fn rem(self, rhs: Self) -> Self {
1279 Self {
1280 x: self.x.rem(rhs.x),
1281 y: self.y.rem(rhs.y),
1282 z: self.z.rem(rhs.z),
1283 }
1284 }
1285}
1286
1287impl Rem<&USizeVec3> for USizeVec3 {
1288 type Output = USizeVec3;
1289 #[inline]
1290 fn rem(self, rhs: &USizeVec3) -> USizeVec3 {
1291 self.rem(*rhs)
1292 }
1293}
1294
1295impl Rem<&USizeVec3> for &USizeVec3 {
1296 type Output = USizeVec3;
1297 #[inline]
1298 fn rem(self, rhs: &USizeVec3) -> USizeVec3 {
1299 (*self).rem(*rhs)
1300 }
1301}
1302
1303impl Rem<USizeVec3> for &USizeVec3 {
1304 type Output = USizeVec3;
1305 #[inline]
1306 fn rem(self, rhs: USizeVec3) -> USizeVec3 {
1307 (*self).rem(rhs)
1308 }
1309}
1310
1311impl RemAssign<USizeVec3> for USizeVec3 {
1312 #[inline]
1313 fn rem_assign(&mut self, rhs: Self) {
1314 self.x.rem_assign(rhs.x);
1315 self.y.rem_assign(rhs.y);
1316 self.z.rem_assign(rhs.z);
1317 }
1318}
1319
1320impl RemAssign<&USizeVec3> for USizeVec3 {
1321 #[inline]
1322 fn rem_assign(&mut self, rhs: &USizeVec3) {
1323 self.rem_assign(*rhs)
1324 }
1325}
1326
1327impl Rem<usize> for USizeVec3 {
1328 type Output = Self;
1329 #[inline]
1330 fn rem(self, rhs: usize) -> Self {
1331 Self {
1332 x: self.x.rem(rhs),
1333 y: self.y.rem(rhs),
1334 z: self.z.rem(rhs),
1335 }
1336 }
1337}
1338
1339impl Rem<&usize> for USizeVec3 {
1340 type Output = USizeVec3;
1341 #[inline]
1342 fn rem(self, rhs: &usize) -> USizeVec3 {
1343 self.rem(*rhs)
1344 }
1345}
1346
1347impl Rem<&usize> for &USizeVec3 {
1348 type Output = USizeVec3;
1349 #[inline]
1350 fn rem(self, rhs: &usize) -> USizeVec3 {
1351 (*self).rem(*rhs)
1352 }
1353}
1354
1355impl Rem<usize> for &USizeVec3 {
1356 type Output = USizeVec3;
1357 #[inline]
1358 fn rem(self, rhs: usize) -> USizeVec3 {
1359 (*self).rem(rhs)
1360 }
1361}
1362
1363impl RemAssign<usize> for USizeVec3 {
1364 #[inline]
1365 fn rem_assign(&mut self, rhs: usize) {
1366 self.x.rem_assign(rhs);
1367 self.y.rem_assign(rhs);
1368 self.z.rem_assign(rhs);
1369 }
1370}
1371
1372impl RemAssign<&usize> for USizeVec3 {
1373 #[inline]
1374 fn rem_assign(&mut self, rhs: &usize) {
1375 self.rem_assign(*rhs)
1376 }
1377}
1378
1379impl Rem<USizeVec3> for usize {
1380 type Output = USizeVec3;
1381 #[inline]
1382 fn rem(self, rhs: USizeVec3) -> USizeVec3 {
1383 USizeVec3 {
1384 x: self.rem(rhs.x),
1385 y: self.rem(rhs.y),
1386 z: self.rem(rhs.z),
1387 }
1388 }
1389}
1390
1391impl Rem<&USizeVec3> for usize {
1392 type Output = USizeVec3;
1393 #[inline]
1394 fn rem(self, rhs: &USizeVec3) -> USizeVec3 {
1395 self.rem(*rhs)
1396 }
1397}
1398
1399impl Rem<&USizeVec3> for &usize {
1400 type Output = USizeVec3;
1401 #[inline]
1402 fn rem(self, rhs: &USizeVec3) -> USizeVec3 {
1403 (*self).rem(*rhs)
1404 }
1405}
1406
1407impl Rem<USizeVec3> for &usize {
1408 type Output = USizeVec3;
1409 #[inline]
1410 fn rem(self, rhs: USizeVec3) -> USizeVec3 {
1411 (*self).rem(rhs)
1412 }
1413}
1414
1415#[cfg(not(target_arch = "spirv"))]
1416impl AsRef<[usize; 3]> for USizeVec3 {
1417 #[inline]
1418 fn as_ref(&self) -> &[usize; 3] {
1419 unsafe { &*(self as *const USizeVec3 as *const [usize; 3]) }
1420 }
1421}
1422
1423#[cfg(not(target_arch = "spirv"))]
1424impl AsMut<[usize; 3]> for USizeVec3 {
1425 #[inline]
1426 fn as_mut(&mut self) -> &mut [usize; 3] {
1427 unsafe { &mut *(self as *mut USizeVec3 as *mut [usize; 3]) }
1428 }
1429}
1430
1431impl Sum for USizeVec3 {
1432 #[inline]
1433 fn sum<I>(iter: I) -> Self
1434 where
1435 I: Iterator<Item = Self>,
1436 {
1437 iter.fold(Self::ZERO, Self::add)
1438 }
1439}
1440
1441impl<'a> Sum<&'a Self> for USizeVec3 {
1442 #[inline]
1443 fn sum<I>(iter: I) -> Self
1444 where
1445 I: Iterator<Item = &'a Self>,
1446 {
1447 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1448 }
1449}
1450
1451impl Product for USizeVec3 {
1452 #[inline]
1453 fn product<I>(iter: I) -> Self
1454 where
1455 I: Iterator<Item = Self>,
1456 {
1457 iter.fold(Self::ONE, Self::mul)
1458 }
1459}
1460
1461impl<'a> Product<&'a Self> for USizeVec3 {
1462 #[inline]
1463 fn product<I>(iter: I) -> Self
1464 where
1465 I: Iterator<Item = &'a Self>,
1466 {
1467 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1468 }
1469}
1470
1471impl Not for USizeVec3 {
1472 type Output = Self;
1473 #[inline]
1474 fn not(self) -> Self::Output {
1475 Self {
1476 x: self.x.not(),
1477 y: self.y.not(),
1478 z: self.z.not(),
1479 }
1480 }
1481}
1482
1483impl BitAnd for USizeVec3 {
1484 type Output = Self;
1485 #[inline]
1486 fn bitand(self, rhs: Self) -> Self::Output {
1487 Self {
1488 x: self.x.bitand(rhs.x),
1489 y: self.y.bitand(rhs.y),
1490 z: self.z.bitand(rhs.z),
1491 }
1492 }
1493}
1494
1495impl BitOr for USizeVec3 {
1496 type Output = Self;
1497 #[inline]
1498 fn bitor(self, rhs: Self) -> Self::Output {
1499 Self {
1500 x: self.x.bitor(rhs.x),
1501 y: self.y.bitor(rhs.y),
1502 z: self.z.bitor(rhs.z),
1503 }
1504 }
1505}
1506
1507impl BitXor for USizeVec3 {
1508 type Output = Self;
1509 #[inline]
1510 fn bitxor(self, rhs: Self) -> Self::Output {
1511 Self {
1512 x: self.x.bitxor(rhs.x),
1513 y: self.y.bitxor(rhs.y),
1514 z: self.z.bitxor(rhs.z),
1515 }
1516 }
1517}
1518
1519impl BitAnd<usize> for USizeVec3 {
1520 type Output = Self;
1521 #[inline]
1522 fn bitand(self, rhs: usize) -> Self::Output {
1523 Self {
1524 x: self.x.bitand(rhs),
1525 y: self.y.bitand(rhs),
1526 z: self.z.bitand(rhs),
1527 }
1528 }
1529}
1530
1531impl BitOr<usize> for USizeVec3 {
1532 type Output = Self;
1533 #[inline]
1534 fn bitor(self, rhs: usize) -> Self::Output {
1535 Self {
1536 x: self.x.bitor(rhs),
1537 y: self.y.bitor(rhs),
1538 z: self.z.bitor(rhs),
1539 }
1540 }
1541}
1542
1543impl BitXor<usize> for USizeVec3 {
1544 type Output = Self;
1545 #[inline]
1546 fn bitxor(self, rhs: usize) -> Self::Output {
1547 Self {
1548 x: self.x.bitxor(rhs),
1549 y: self.y.bitxor(rhs),
1550 z: self.z.bitxor(rhs),
1551 }
1552 }
1553}
1554
1555impl Shl<i8> for USizeVec3 {
1556 type Output = Self;
1557 #[inline]
1558 fn shl(self, rhs: i8) -> Self::Output {
1559 Self {
1560 x: self.x.shl(rhs),
1561 y: self.y.shl(rhs),
1562 z: self.z.shl(rhs),
1563 }
1564 }
1565}
1566
1567impl Shr<i8> for USizeVec3 {
1568 type Output = Self;
1569 #[inline]
1570 fn shr(self, rhs: i8) -> Self::Output {
1571 Self {
1572 x: self.x.shr(rhs),
1573 y: self.y.shr(rhs),
1574 z: self.z.shr(rhs),
1575 }
1576 }
1577}
1578
1579impl Shl<i16> for USizeVec3 {
1580 type Output = Self;
1581 #[inline]
1582 fn shl(self, rhs: i16) -> Self::Output {
1583 Self {
1584 x: self.x.shl(rhs),
1585 y: self.y.shl(rhs),
1586 z: self.z.shl(rhs),
1587 }
1588 }
1589}
1590
1591impl Shr<i16> for USizeVec3 {
1592 type Output = Self;
1593 #[inline]
1594 fn shr(self, rhs: i16) -> Self::Output {
1595 Self {
1596 x: self.x.shr(rhs),
1597 y: self.y.shr(rhs),
1598 z: self.z.shr(rhs),
1599 }
1600 }
1601}
1602
1603impl Shl<i32> for USizeVec3 {
1604 type Output = Self;
1605 #[inline]
1606 fn shl(self, rhs: i32) -> Self::Output {
1607 Self {
1608 x: self.x.shl(rhs),
1609 y: self.y.shl(rhs),
1610 z: self.z.shl(rhs),
1611 }
1612 }
1613}
1614
1615impl Shr<i32> for USizeVec3 {
1616 type Output = Self;
1617 #[inline]
1618 fn shr(self, rhs: i32) -> Self::Output {
1619 Self {
1620 x: self.x.shr(rhs),
1621 y: self.y.shr(rhs),
1622 z: self.z.shr(rhs),
1623 }
1624 }
1625}
1626
1627impl Shl<i64> for USizeVec3 {
1628 type Output = Self;
1629 #[inline]
1630 fn shl(self, rhs: i64) -> Self::Output {
1631 Self {
1632 x: self.x.shl(rhs),
1633 y: self.y.shl(rhs),
1634 z: self.z.shl(rhs),
1635 }
1636 }
1637}
1638
1639impl Shr<i64> for USizeVec3 {
1640 type Output = Self;
1641 #[inline]
1642 fn shr(self, rhs: i64) -> Self::Output {
1643 Self {
1644 x: self.x.shr(rhs),
1645 y: self.y.shr(rhs),
1646 z: self.z.shr(rhs),
1647 }
1648 }
1649}
1650
1651impl Shl<u8> for USizeVec3 {
1652 type Output = Self;
1653 #[inline]
1654 fn shl(self, rhs: u8) -> Self::Output {
1655 Self {
1656 x: self.x.shl(rhs),
1657 y: self.y.shl(rhs),
1658 z: self.z.shl(rhs),
1659 }
1660 }
1661}
1662
1663impl Shr<u8> for USizeVec3 {
1664 type Output = Self;
1665 #[inline]
1666 fn shr(self, rhs: u8) -> Self::Output {
1667 Self {
1668 x: self.x.shr(rhs),
1669 y: self.y.shr(rhs),
1670 z: self.z.shr(rhs),
1671 }
1672 }
1673}
1674
1675impl Shl<u16> for USizeVec3 {
1676 type Output = Self;
1677 #[inline]
1678 fn shl(self, rhs: u16) -> Self::Output {
1679 Self {
1680 x: self.x.shl(rhs),
1681 y: self.y.shl(rhs),
1682 z: self.z.shl(rhs),
1683 }
1684 }
1685}
1686
1687impl Shr<u16> for USizeVec3 {
1688 type Output = Self;
1689 #[inline]
1690 fn shr(self, rhs: u16) -> Self::Output {
1691 Self {
1692 x: self.x.shr(rhs),
1693 y: self.y.shr(rhs),
1694 z: self.z.shr(rhs),
1695 }
1696 }
1697}
1698
1699impl Shl<u32> for USizeVec3 {
1700 type Output = Self;
1701 #[inline]
1702 fn shl(self, rhs: u32) -> Self::Output {
1703 Self {
1704 x: self.x.shl(rhs),
1705 y: self.y.shl(rhs),
1706 z: self.z.shl(rhs),
1707 }
1708 }
1709}
1710
1711impl Shr<u32> for USizeVec3 {
1712 type Output = Self;
1713 #[inline]
1714 fn shr(self, rhs: u32) -> Self::Output {
1715 Self {
1716 x: self.x.shr(rhs),
1717 y: self.y.shr(rhs),
1718 z: self.z.shr(rhs),
1719 }
1720 }
1721}
1722
1723impl Shl<u64> for USizeVec3 {
1724 type Output = Self;
1725 #[inline]
1726 fn shl(self, rhs: u64) -> Self::Output {
1727 Self {
1728 x: self.x.shl(rhs),
1729 y: self.y.shl(rhs),
1730 z: self.z.shl(rhs),
1731 }
1732 }
1733}
1734
1735impl Shr<u64> for USizeVec3 {
1736 type Output = Self;
1737 #[inline]
1738 fn shr(self, rhs: u64) -> Self::Output {
1739 Self {
1740 x: self.x.shr(rhs),
1741 y: self.y.shr(rhs),
1742 z: self.z.shr(rhs),
1743 }
1744 }
1745}
1746
1747impl Shl<crate::IVec3> for USizeVec3 {
1748 type Output = Self;
1749 #[inline]
1750 fn shl(self, rhs: crate::IVec3) -> Self::Output {
1751 Self {
1752 x: self.x.shl(rhs.x),
1753 y: self.y.shl(rhs.y),
1754 z: self.z.shl(rhs.z),
1755 }
1756 }
1757}
1758
1759impl Shr<crate::IVec3> for USizeVec3 {
1760 type Output = Self;
1761 #[inline]
1762 fn shr(self, rhs: crate::IVec3) -> Self::Output {
1763 Self {
1764 x: self.x.shr(rhs.x),
1765 y: self.y.shr(rhs.y),
1766 z: self.z.shr(rhs.z),
1767 }
1768 }
1769}
1770
1771impl Shl<crate::UVec3> for USizeVec3 {
1772 type Output = Self;
1773 #[inline]
1774 fn shl(self, rhs: crate::UVec3) -> Self::Output {
1775 Self {
1776 x: self.x.shl(rhs.x),
1777 y: self.y.shl(rhs.y),
1778 z: self.z.shl(rhs.z),
1779 }
1780 }
1781}
1782
1783impl Shr<crate::UVec3> for USizeVec3 {
1784 type Output = Self;
1785 #[inline]
1786 fn shr(self, rhs: crate::UVec3) -> Self::Output {
1787 Self {
1788 x: self.x.shr(rhs.x),
1789 y: self.y.shr(rhs.y),
1790 z: self.z.shr(rhs.z),
1791 }
1792 }
1793}
1794
1795impl Index<usize> for USizeVec3 {
1796 type Output = usize;
1797 #[inline]
1798 fn index(&self, index: usize) -> &Self::Output {
1799 match index {
1800 0 => &self.x,
1801 1 => &self.y,
1802 2 => &self.z,
1803 _ => panic!("index out of bounds"),
1804 }
1805 }
1806}
1807
1808impl IndexMut<usize> for USizeVec3 {
1809 #[inline]
1810 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1811 match index {
1812 0 => &mut self.x,
1813 1 => &mut self.y,
1814 2 => &mut self.z,
1815 _ => panic!("index out of bounds"),
1816 }
1817 }
1818}
1819
1820impl fmt::Display for USizeVec3 {
1821 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1822 write!(f, "[{}, {}, {}]", self.x, self.y, self.z)
1823 }
1824}
1825
1826impl fmt::Debug for USizeVec3 {
1827 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1828 fmt.debug_tuple(stringify!(USizeVec3))
1829 .field(&self.x)
1830 .field(&self.y)
1831 .field(&self.z)
1832 .finish()
1833 }
1834}
1835
1836impl From<[usize; 3]> for USizeVec3 {
1837 #[inline]
1838 fn from(a: [usize; 3]) -> Self {
1839 Self::new(a[0], a[1], a[2])
1840 }
1841}
1842
1843impl From<USizeVec3> for [usize; 3] {
1844 #[inline]
1845 fn from(v: USizeVec3) -> Self {
1846 [v.x, v.y, v.z]
1847 }
1848}
1849
1850impl From<(usize, usize, usize)> for USizeVec3 {
1851 #[inline]
1852 fn from(t: (usize, usize, usize)) -> Self {
1853 Self::new(t.0, t.1, t.2)
1854 }
1855}
1856
1857impl From<USizeVec3> for (usize, usize, usize) {
1858 #[inline]
1859 fn from(v: USizeVec3) -> Self {
1860 (v.x, v.y, v.z)
1861 }
1862}
1863
1864impl From<(USizeVec2, usize)> for USizeVec3 {
1865 #[inline]
1866 fn from((v, z): (USizeVec2, usize)) -> Self {
1867 Self::new(v.x, v.y, z)
1868 }
1869}
1870
1871impl From<U8Vec3> for USizeVec3 {
1872 #[inline]
1873 fn from(v: U8Vec3) -> Self {
1874 Self::new(usize::from(v.x), usize::from(v.y), usize::from(v.z))
1875 }
1876}
1877
1878impl From<U16Vec3> for USizeVec3 {
1879 #[inline]
1880 fn from(v: U16Vec3) -> Self {
1881 Self::new(usize::from(v.x), usize::from(v.y), usize::from(v.z))
1882 }
1883}
1884
1885impl TryFrom<I8Vec3> for USizeVec3 {
1886 type Error = core::num::TryFromIntError;
1887
1888 #[inline]
1889 fn try_from(v: I8Vec3) -> Result<Self, Self::Error> {
1890 Ok(Self::new(
1891 usize::try_from(v.x)?,
1892 usize::try_from(v.y)?,
1893 usize::try_from(v.z)?,
1894 ))
1895 }
1896}
1897
1898impl TryFrom<I16Vec3> for USizeVec3 {
1899 type Error = core::num::TryFromIntError;
1900
1901 #[inline]
1902 fn try_from(v: I16Vec3) -> Result<Self, Self::Error> {
1903 Ok(Self::new(
1904 usize::try_from(v.x)?,
1905 usize::try_from(v.y)?,
1906 usize::try_from(v.z)?,
1907 ))
1908 }
1909}
1910
1911impl TryFrom<IVec3> for USizeVec3 {
1912 type Error = core::num::TryFromIntError;
1913
1914 #[inline]
1915 fn try_from(v: IVec3) -> Result<Self, Self::Error> {
1916 Ok(Self::new(
1917 usize::try_from(v.x)?,
1918 usize::try_from(v.y)?,
1919 usize::try_from(v.z)?,
1920 ))
1921 }
1922}
1923
1924impl TryFrom<I64Vec3> for USizeVec3 {
1925 type Error = core::num::TryFromIntError;
1926
1927 #[inline]
1928 fn try_from(v: I64Vec3) -> Result<Self, Self::Error> {
1929 Ok(Self::new(
1930 usize::try_from(v.x)?,
1931 usize::try_from(v.y)?,
1932 usize::try_from(v.z)?,
1933 ))
1934 }
1935}
1936
1937impl TryFrom<UVec3> for USizeVec3 {
1938 type Error = core::num::TryFromIntError;
1939
1940 #[inline]
1941 fn try_from(v: UVec3) -> Result<Self, Self::Error> {
1942 Ok(Self::new(
1943 usize::try_from(v.x)?,
1944 usize::try_from(v.y)?,
1945 usize::try_from(v.z)?,
1946 ))
1947 }
1948}
1949
1950impl TryFrom<U64Vec3> for USizeVec3 {
1951 type Error = core::num::TryFromIntError;
1952
1953 #[inline]
1954 fn try_from(v: U64Vec3) -> Result<Self, Self::Error> {
1955 Ok(Self::new(
1956 usize::try_from(v.x)?,
1957 usize::try_from(v.y)?,
1958 usize::try_from(v.z)?,
1959 ))
1960 }
1961}
1962
1963impl From<BVec3> for USizeVec3 {
1964 #[inline]
1965 fn from(v: BVec3) -> Self {
1966 Self::new(usize::from(v.x), usize::from(v.y), usize::from(v.z))
1967 }
1968}
1969
1970impl From<BVec3A> for USizeVec3 {
1971 #[inline]
1972 fn from(v: BVec3A) -> Self {
1973 let bool_array: [bool; 3] = v.into();
1974 Self::new(
1975 usize::from(bool_array[0]),
1976 usize::from(bool_array[1]),
1977 usize::from(bool_array[2]),
1978 )
1979 }
1980}