Debian Codegraph @

debian/missing-sources/glam-0.23.0/src/u32/uvec2.rs

raw symbols SCIP
1 // Generated from vec.rs.tera template. Edit the template, not the generated file.
2
3 use crate::{BVec2, UVec3};
4
5 #[cfg(not(target_arch = "spirv"))]
6 use core::fmt;
7 use core::iter::{Product, Sum};
8 use core::{f32, ops::*};
9
10 /// Creates a 2-dimensional vector.
11 #[inline(always)]
12 pub const fn uvec2(x: u32, y: u32) -> UVec2 {
13 UVec2::new(x, y)
14 }
15
16 /// A 2-dimensional vector.
17 #[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
18 #[derive(Clone, Copy, PartialEq, Eq)]
19 #[cfg_attr(feature = "cuda", repr(align(8)))]
20 #[cfg_attr(not(target_arch = "spirv"), repr(C))]
21 #[cfg_attr(target_arch = "spirv", repr(simd))]
22 pub struct UVec2 {
23 pub x: u32,
24 pub y: u32,
25 }
26
27 impl UVec2 {
28 /// All zeroes.
29 pub const ZERO: Self = Self::splat(0);
30
31 /// All ones.
32 pub const ONE: Self = Self::splat(1);
33
34 /// A unit-length vector pointing along the positive X axis.
35 pub const X: Self = Self::new(1, 0);
36
37 /// A unit-length vector pointing along the positive Y axis.
38 pub const Y: Self = Self::new(0, 1);
39
40 /// The unit axes.
41 pub const AXES: [Self; 2] = [Self::X, Self::Y];
42
43 /// Creates a new vector.
44 #[inline(always)]
45 pub const fn new(x: u32, y: u32) -> Self {
46 Self { x, y }
47 }
48
49 /// Creates a vector with all elements set to `v`.
50 #[inline]
51 pub const fn splat(v: u32) -> Self {
52 Self { x: v, y: v }
53 }
54
55 /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
56 /// for each element of `self`.
57 ///
58 /// A true element in the mask uses the corresponding element from `if_true`, and false
59 /// uses the element from `if_false`.
60 #[inline]
61 pub fn select(mask: BVec2, if_true: Self, if_false: Self) -> Self {
62 Self {
63 x: if mask.x { if_true.x } else { if_false.x },
64 y: if mask.y { if_true.y } else { if_false.y },
65 }
66 }
67
68 /// Creates a new vector from an array.
69 #[inline]
70 pub const fn from_array(a: [u32; 2]) -> Self {
71 Self::new(a[0], a[1])
72 }
73
74 /// `[x, y]`
75 #[inline]
76 pub const fn to_array(&self) -> [u32; 2] {
77 [self.x, self.y]
78 }
79
80 /// Creates a vector from the first 2 values in `slice`.
81 ///
82 /// # Panics
83 ///
84 /// Panics if `slice` is less than 2 elements long.
85 #[inline]
86 pub const fn from_slice(slice: &[u32]) -> Self {
87 Self::new(slice[0], slice[1])
88 }
89
90 /// Writes the elements of `self` to the first 2 elements in `slice`.
91 ///
92 /// # Panics
93 ///
94 /// Panics if `slice` is less than 2 elements long.
95 #[inline]
96 pub fn write_to_slice(self, slice: &mut [u32]) {
97 slice[0] = self.x;
98 slice[1] = self.y;
99 }
100
101 /// Creates a 3D vector from `self` and the given `z` value.
102 #[inline]
103 pub const fn extend(self, z: u32) -> UVec3 {
104 UVec3::new(self.x, self.y, z)
105 }
106
107 /// Computes the dot product of `self` and `rhs`.
108 #[inline]
109 pub fn dot(self, rhs: Self) -> u32 {
110 (self.x * rhs.x) + (self.y * rhs.y)
111 }
112
113 /// Returns a vector where every component is the dot product of `self` and `rhs`.
114 #[inline]
115 pub fn dot_into_vec(self, rhs: Self) -> Self {
116 Self::splat(self.dot(rhs))
117 }
118
119 /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
120 ///
121 /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
122 #[inline]
123 pub fn min(self, rhs: Self) -> Self {
124 Self {
125 x: self.x.min(rhs.x),
126 y: self.y.min(rhs.y),
127 }
128 }
129
130 /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
131 ///
132 /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
133 #[inline]
134 pub fn max(self, rhs: Self) -> Self {
135 Self {
136 x: self.x.max(rhs.x),
137 y: self.y.max(rhs.y),
138 }
139 }
140
141 /// Component-wise clamping of values, similar to [`u32::clamp`].
142 ///
143 /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
144 ///
145 /// # Panics
146 ///
147 /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
148 #[inline]
149 pub fn clamp(self, min: Self, max: Self) -> Self {
150 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
151 self.max(min).min(max)
152 }
153
154 /// Returns the horizontal minimum of `self`.
155 ///
156 /// In other words this computes `min(x, y, ..)`.
157 #[inline]
158 pub fn min_element(self) -> u32 {
159 self.x.min(self.y)
160 }
161
162 /// Returns the horizontal maximum of `self`.
163 ///
164 /// In other words this computes `max(x, y, ..)`.
165 #[inline]
166 pub fn max_element(self) -> u32 {
167 self.x.max(self.y)
168 }
169
170 /// Returns a vector mask containing the result of a `==` comparison for each element of
171 /// `self` and `rhs`.
172 ///
173 /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
174 /// elements.
175 #[inline]
176 pub fn cmpeq(self, rhs: Self) -> BVec2 {
177 BVec2::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y))
178 }
179
180 /// Returns a vector mask containing the result of a `!=` comparison for each element of
181 /// `self` and `rhs`.
182 ///
183 /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
184 /// elements.
185 #[inline]
186 pub fn cmpne(self, rhs: Self) -> BVec2 {
187 BVec2::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y))
188 }
189
190 /// Returns a vector mask containing the result of a `>=` comparison for each element of
191 /// `self` and `rhs`.
192 ///
193 /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
194 /// elements.
195 #[inline]
196 pub fn cmpge(self, rhs: Self) -> BVec2 {
197 BVec2::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y))
198 }
199
200 /// Returns a vector mask containing the result of a `>` comparison for each element of
201 /// `self` and `rhs`.
202 ///
203 /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
204 /// elements.
205 #[inline]
206 pub fn cmpgt(self, rhs: Self) -> BVec2 {
207 BVec2::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y))
208 }
209
210 /// Returns a vector mask containing the result of a `<=` comparison for each element of
211 /// `self` and `rhs`.
212 ///
213 /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
214 /// elements.
215 #[inline]
216 pub fn cmple(self, rhs: Self) -> BVec2 {
217 BVec2::new(self.x.le(&rhs.x), self.y.le(&rhs.y))
218 }
219
220 /// Returns a vector mask containing the result of a `<` comparison for each element of
221 /// `self` and `rhs`.
222 ///
223 /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
224 /// elements.
225 #[inline]
226 pub fn cmplt(self, rhs: Self) -> BVec2 {
227 BVec2::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y))
228 }
229
230 /// Casts all elements of `self` to `f32`.
231 #[inline]
232 pub fn as_vec2(&self) -> crate::Vec2 {
233 crate::Vec2::new(self.x as f32, self.y as f32)
234 }
235
236 /// Casts all elements of `self` to `f64`.
237 #[inline]
238 pub fn as_dvec2(&self) -> crate::DVec2 {
239 crate::DVec2::new(self.x as f64, self.y as f64)
240 }
241
242 /// Casts all elements of `self` to `i32`.
243 #[inline]
244 pub fn as_ivec2(&self) -> crate::IVec2 {
245 crate::IVec2::new(self.x as i32, self.y as i32)
246 }
247 }
248
249 impl Default for UVec2 {
250 #[inline(always)]
251 fn default() -> Self {
252 Self::ZERO
253 }
254 }
255
256 impl Div<UVec2> for UVec2 {
257 type Output = Self;
258 #[inline]
259 fn div(self, rhs: Self) -> Self {
260 Self {
261 x: self.x.div(rhs.x),
262 y: self.y.div(rhs.y),
263 }
264 }
265 }
266
267 impl DivAssign<UVec2> for UVec2 {
268 #[inline]
269 fn div_assign(&mut self, rhs: Self) {
270 self.x.div_assign(rhs.x);
271 self.y.div_assign(rhs.y);
272 }
273 }
274
275 impl Div<u32> for UVec2 {
276 type Output = Self;
277 #[inline]
278 fn div(self, rhs: u32) -> Self {
279 Self {
280 x: self.x.div(rhs),
281 y: self.y.div(rhs),
282 }
283 }
284 }
285
286 impl DivAssign<u32> for UVec2 {
287 #[inline]
288 fn div_assign(&mut self, rhs: u32) {
289 self.x.div_assign(rhs);
290 self.y.div_assign(rhs);
291 }
292 }
293
294 impl Div<UVec2> for u32 {
295 type Output = UVec2;
296 #[inline]
297 fn div(self, rhs: UVec2) -> UVec2 {
298 UVec2 {
299 x: self.div(rhs.x),
300 y: self.div(rhs.y),
301 }
302 }
303 }
304
305 impl Mul<UVec2> for UVec2 {
306 type Output = Self;
307 #[inline]
308 fn mul(self, rhs: Self) -> Self {
309 Self {
310 x: self.x.mul(rhs.x),
311 y: self.y.mul(rhs.y),
312 }
313 }
314 }
315
316 impl MulAssign<UVec2> for UVec2 {
317 #[inline]
318 fn mul_assign(&mut self, rhs: Self) {
319 self.x.mul_assign(rhs.x);
320 self.y.mul_assign(rhs.y);
321 }
322 }
323
324 impl Mul<u32> for UVec2 {
325 type Output = Self;
326 #[inline]
327 fn mul(self, rhs: u32) -> Self {
328 Self {
329 x: self.x.mul(rhs),
330 y: self.y.mul(rhs),
331 }
332 }
333 }
334
335 impl MulAssign<u32> for UVec2 {
336 #[inline]
337 fn mul_assign(&mut self, rhs: u32) {
338 self.x.mul_assign(rhs);
339 self.y.mul_assign(rhs);
340 }
341 }
342
343 impl Mul<UVec2> for u32 {
344 type Output = UVec2;
345 #[inline]
346 fn mul(self, rhs: UVec2) -> UVec2 {
347 UVec2 {
348 x: self.mul(rhs.x),
349 y: self.mul(rhs.y),
350 }
351 }
352 }
353
354 impl Add<UVec2> for UVec2 {
355 type Output = Self;
356 #[inline]
357 fn add(self, rhs: Self) -> Self {
358 Self {
359 x: self.x.add(rhs.x),
360 y: self.y.add(rhs.y),
361 }
362 }
363 }
364
365 impl AddAssign<UVec2> for UVec2 {
366 #[inline]
367 fn add_assign(&mut self, rhs: Self) {
368 self.x.add_assign(rhs.x);
369 self.y.add_assign(rhs.y);
370 }
371 }
372
373 impl Add<u32> for UVec2 {
374 type Output = Self;
375 #[inline]
376 fn add(self, rhs: u32) -> Self {
377 Self {
378 x: self.x.add(rhs),
379 y: self.y.add(rhs),
380 }
381 }
382 }
383
384 impl AddAssign<u32> for UVec2 {
385 #[inline]
386 fn add_assign(&mut self, rhs: u32) {
387 self.x.add_assign(rhs);
388 self.y.add_assign(rhs);
389 }
390 }
391
392 impl Add<UVec2> for u32 {
393 type Output = UVec2;
394 #[inline]
395 fn add(self, rhs: UVec2) -> UVec2 {
396 UVec2 {
397 x: self.add(rhs.x),
398 y: self.add(rhs.y),
399 }
400 }
401 }
402
403 impl Sub<UVec2> for UVec2 {
404 type Output = Self;
405 #[inline]
406 fn sub(self, rhs: Self) -> Self {
407 Self {
408 x: self.x.sub(rhs.x),
409 y: self.y.sub(rhs.y),
410 }
411 }
412 }
413
414 impl SubAssign<UVec2> for UVec2 {
415 #[inline]
416 fn sub_assign(&mut self, rhs: UVec2) {
417 self.x.sub_assign(rhs.x);
418 self.y.sub_assign(rhs.y);
419 }
420 }
421
422 impl Sub<u32> for UVec2 {
423 type Output = Self;
424 #[inline]
425 fn sub(self, rhs: u32) -> Self {
426 Self {
427 x: self.x.sub(rhs),
428 y: self.y.sub(rhs),
429 }
430 }
431 }
432
433 impl SubAssign<u32> for UVec2 {
434 #[inline]
435 fn sub_assign(&mut self, rhs: u32) {
436 self.x.sub_assign(rhs);
437 self.y.sub_assign(rhs);
438 }
439 }
440
441 impl Sub<UVec2> for u32 {
442 type Output = UVec2;
443 #[inline]
444 fn sub(self, rhs: UVec2) -> UVec2 {
445 UVec2 {
446 x: self.sub(rhs.x),
447 y: self.sub(rhs.y),
448 }
449 }
450 }
451
452 impl Rem<UVec2> for UVec2 {
453 type Output = Self;
454 #[inline]
455 fn rem(self, rhs: Self) -> Self {
456 Self {
457 x: self.x.rem(rhs.x),
458 y: self.y.rem(rhs.y),
459 }
460 }
461 }
462
463 impl RemAssign<UVec2> for UVec2 {
464 #[inline]
465 fn rem_assign(&mut self, rhs: Self) {
466 self.x.rem_assign(rhs.x);
467 self.y.rem_assign(rhs.y);
468 }
469 }
470
471 impl Rem<u32> for UVec2 {
472 type Output = Self;
473 #[inline]
474 fn rem(self, rhs: u32) -> Self {
475 Self {
476 x: self.x.rem(rhs),
477 y: self.y.rem(rhs),
478 }
479 }
480 }
481
482 impl RemAssign<u32> for UVec2 {
483 #[inline]
484 fn rem_assign(&mut self, rhs: u32) {
485 self.x.rem_assign(rhs);
486 self.y.rem_assign(rhs);
487 }
488 }
489
490 impl Rem<UVec2> for u32 {
491 type Output = UVec2;
492 #[inline]
493 fn rem(self, rhs: UVec2) -> UVec2 {
494 UVec2 {
495 x: self.rem(rhs.x),
496 y: self.rem(rhs.y),
497 }
498 }
499 }
500
501 #[cfg(not(target_arch = "spirv"))]
502 impl AsRef<[u32; 2]> for UVec2 {
503 #[inline]
504 fn as_ref(&self) -> &[u32; 2] {
505 unsafe { &*(self as *const UVec2 as *const [u32; 2]) }
506 }
507 }
508
509 #[cfg(not(target_arch = "spirv"))]
510 impl AsMut<[u32; 2]> for UVec2 {
511 #[inline]
512 fn as_mut(&mut self) -> &mut [u32; 2] {
513 unsafe { &mut *(self as *mut UVec2 as *mut [u32; 2]) }
514 }
515 }
516
517 impl Sum for UVec2 {
518 #[inline]
519 fn sum<I>(iter: I) -> Self
520 where
521 I: Iterator<Item = Self>,
522 {
523 iter.fold(Self::ZERO, Self::add)
524 }
525 }
526
527 impl<'a> Sum<&'a Self> for UVec2 {
528 #[inline]
529 fn sum<I>(iter: I) -> Self
530 where
531 I: Iterator<Item = &'a Self>,
532 {
533 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
534 }
535 }
536
537 impl Product for UVec2 {
538 #[inline]
539 fn product<I>(iter: I) -> Self
540 where
541 I: Iterator<Item = Self>,
542 {
543 iter.fold(Self::ONE, Self::mul)
544 }
545 }
546
547 impl<'a> Product<&'a Self> for UVec2 {
548 #[inline]
549 fn product<I>(iter: I) -> Self
550 where
551 I: Iterator<Item = &'a Self>,
552 {
553 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
554 }
555 }
556
557 impl Not for UVec2 {
558 type Output = Self;
559 #[inline]
560 fn not(self) -> Self::Output {
561 Self {
562 x: self.x.not(),
563 y: self.y.not(),
564 }
565 }
566 }
567
568 impl BitAnd for UVec2 {
569 type Output = Self;
570 #[inline]
571 fn bitand(self, rhs: Self) -> Self::Output {
572 Self {
573 x: self.x.bitand(rhs.x),
574 y: self.y.bitand(rhs.y),
575 }
576 }
577 }
578
579 impl BitOr for UVec2 {
580 type Output = Self;
581 #[inline]
582 fn bitor(self, rhs: Self) -> Self::Output {
583 Self {
584 x: self.x.bitor(rhs.x),
585 y: self.y.bitor(rhs.y),
586 }
587 }
588 }
589
590 impl BitXor for UVec2 {
591 type Output = Self;
592 #[inline]
593 fn bitxor(self, rhs: Self) -> Self::Output {
594 Self {
595 x: self.x.bitxor(rhs.x),
596 y: self.y.bitxor(rhs.y),
597 }
598 }
599 }
600
601 impl BitAnd<u32> for UVec2 {
602 type Output = Self;
603 #[inline]
604 fn bitand(self, rhs: u32) -> Self::Output {
605 Self {
606 x: self.x.bitand(rhs),
607 y: self.y.bitand(rhs),
608 }
609 }
610 }
611
612 impl BitOr<u32> for UVec2 {
613 type Output = Self;
614 #[inline]
615 fn bitor(self, rhs: u32) -> Self::Output {
616 Self {
617 x: self.x.bitor(rhs),
618 y: self.y.bitor(rhs),
619 }
620 }
621 }
622
623 impl BitXor<u32> for UVec2 {
624 type Output = Self;
625 #[inline]
626 fn bitxor(self, rhs: u32) -> Self::Output {
627 Self {
628 x: self.x.bitxor(rhs),
629 y: self.y.bitxor(rhs),
630 }
631 }
632 }
633
634 impl Shl<i8> for UVec2 {
635 type Output = Self;
636 #[inline]
637 fn shl(self, rhs: i8) -> Self::Output {
638 Self {
639 x: self.x.shl(rhs),
640 y: self.y.shl(rhs),
641 }
642 }
643 }
644
645 impl Shr<i8> for UVec2 {
646 type Output = Self;
647 #[inline]
648 fn shr(self, rhs: i8) -> Self::Output {
649 Self {
650 x: self.x.shr(rhs),
651 y: self.y.shr(rhs),
652 }
653 }
654 }
655
656 impl Shl<i16> for UVec2 {
657 type Output = Self;
658 #[inline]
659 fn shl(self, rhs: i16) -> Self::Output {
660 Self {
661 x: self.x.shl(rhs),
662 y: self.y.shl(rhs),
663 }
664 }
665 }
666
667 impl Shr<i16> for UVec2 {
668 type Output = Self;
669 #[inline]
670 fn shr(self, rhs: i16) -> Self::Output {
671 Self {
672 x: self.x.shr(rhs),
673 y: self.y.shr(rhs),
674 }
675 }
676 }
677
678 impl Shl<i32> for UVec2 {
679 type Output = Self;
680 #[inline]
681 fn shl(self, rhs: i32) -> Self::Output {
682 Self {
683 x: self.x.shl(rhs),
684 y: self.y.shl(rhs),
685 }
686 }
687 }
688
689 impl Shr<i32> for UVec2 {
690 type Output = Self;
691 #[inline]
692 fn shr(self, rhs: i32) -> Self::Output {
693 Self {
694 x: self.x.shr(rhs),
695 y: self.y.shr(rhs),
696 }
697 }
698 }
699
700 impl Shl<u8> for UVec2 {
701 type Output = Self;
702 #[inline]
703 fn shl(self, rhs: u8) -> Self::Output {
704 Self {
705 x: self.x.shl(rhs),
706 y: self.y.shl(rhs),
707 }
708 }
709 }
710
711 impl Shr<u8> for UVec2 {
712 type Output = Self;
713 #[inline]
714 fn shr(self, rhs: u8) -> Self::Output {
715 Self {
716 x: self.x.shr(rhs),
717 y: self.y.shr(rhs),
718 }
719 }
720 }
721
722 impl Shl<u16> for UVec2 {
723 type Output = Self;
724 #[inline]
725 fn shl(self, rhs: u16) -> Self::Output {
726 Self {
727 x: self.x.shl(rhs),
728 y: self.y.shl(rhs),
729 }
730 }
731 }
732
733 impl Shr<u16> for UVec2 {
734 type Output = Self;
735 #[inline]
736 fn shr(self, rhs: u16) -> Self::Output {
737 Self {
738 x: self.x.shr(rhs),
739 y: self.y.shr(rhs),
740 }
741 }
742 }
743
744 impl Shl<u32> for UVec2 {
745 type Output = Self;
746 #[inline]
747 fn shl(self, rhs: u32) -> Self::Output {
748 Self {
749 x: self.x.shl(rhs),
750 y: self.y.shl(rhs),
751 }
752 }
753 }
754
755 impl Shr<u32> for UVec2 {
756 type Output = Self;
757 #[inline]
758 fn shr(self, rhs: u32) -> Self::Output {
759 Self {
760 x: self.x.shr(rhs),
761 y: self.y.shr(rhs),
762 }
763 }
764 }
765
766 impl Shl<crate::IVec2> for UVec2 {
767 type Output = Self;
768 #[inline]
769 fn shl(self, rhs: crate::IVec2) -> Self::Output {
770 Self {
771 x: self.x.shl(rhs.x),
772 y: self.y.shl(rhs.y),
773 }
774 }
775 }
776
777 impl Shr<crate::IVec2> for UVec2 {
778 type Output = Self;
779 #[inline]
780 fn shr(self, rhs: crate::IVec2) -> Self::Output {
781 Self {
782 x: self.x.shr(rhs.x),
783 y: self.y.shr(rhs.y),
784 }
785 }
786 }
787
788 impl Shl<crate::UVec2> for UVec2 {
789 type Output = Self;
790 #[inline]
791 fn shl(self, rhs: crate::UVec2) -> Self::Output {
792 Self {
793 x: self.x.shl(rhs.x),
794 y: self.y.shl(rhs.y),
795 }
796 }
797 }
798
799 impl Shr<crate::UVec2> for UVec2 {
800 type Output = Self;
801 #[inline]
802 fn shr(self, rhs: crate::UVec2) -> Self::Output {
803 Self {
804 x: self.x.shr(rhs.x),
805 y: self.y.shr(rhs.y),
806 }
807 }
808 }
809
810 impl Index<usize> for UVec2 {
811 type Output = u32;
812 #[inline]
813 fn index(&self, index: usize) -> &Self::Output {
814 match index {
815 0 => &self.x,
816 1 => &self.y,
817 _ => panic!("index out of bounds"),
818 }
819 }
820 }
821
822 impl IndexMut<usize> for UVec2 {
823 #[inline]
824 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
825 match index {
826 0 => &mut self.x,
827 1 => &mut self.y,
828 _ => panic!("index out of bounds"),
829 }
830 }
831 }
832
833 #[cfg(not(target_arch = "spirv"))]
834 impl fmt::Display for UVec2 {
835 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
836 write!(f, "[{}, {}]", self.x, self.y)
837 }
838 }
839
840 #[cfg(not(target_arch = "spirv"))]
841 impl fmt::Debug for UVec2 {
842 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
843 fmt.debug_tuple(stringify!(UVec2))
844 .field(&self.x)
845 .field(&self.y)
846 .finish()
847 }
848 }
849
850 impl From<[u32; 2]> for UVec2 {
851 #[inline]
852 fn from(a: [u32; 2]) -> Self {
853 Self::new(a[0], a[1])
854 }
855 }
856
857 impl From<UVec2> for [u32; 2] {
858 #[inline]
859 fn from(v: UVec2) -> Self {
860 [v.x, v.y]
861 }
862 }
863
864 impl From<(u32, u32)> for UVec2 {
865 #[inline]
866 fn from(t: (u32, u32)) -> Self {
867 Self::new(t.0, t.1)
868 }
869 }
870
871 impl From<UVec2> for (u32, u32) {
872 #[inline]
873 fn from(v: UVec2) -> Self {
874 (v.x, v.y)
875 }
876 }