1 // Generated from vec.rs.tera template. Edit the template, not the generated file.
2
3 #[cfg(not(feature = "scalar-math"))]
4 use crate::BVec4A;
5 use crate::{BVec4, I16Vec4, I64Vec4, I8Vec4, IVec4, U16Vec4, U64Vec4, U8Vec4, UVec2, UVec3};
6
7 use core::fmt;
8 use core::iter::{Product, Sum};
9 use core::{f32, ops::*};
10
11 /// Creates a 4-dimensional vector.
12 #[inline(always)]
13 #[must_use]
uvec4(x: u32, y: u32, z: u32, w: u32) -> UVec414 pub const fn uvec4(x: u32, y: u32, z: u32, w: u32) -> UVec4 {
15 UVec4::new(x, y, z, w)
16 }
17
18 /// A 4-dimensional vector.
19 #[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
20 #[derive(Clone, Copy, PartialEq, Eq)]
21 #[cfg_attr(feature = "cuda", repr(align(16)))]
22 #[cfg_attr(not(target_arch = "spirv"), repr(C))]
23 #[cfg_attr(target_arch = "spirv", repr(simd))]
24 pub struct UVec4 {
25 pub x: u32,
26 pub y: u32,
27 pub z: u32,
28 pub w: u32,
29 }
30
31 impl UVec4 {
32 /// All zeroes.
33 pub const ZERO: Self = Self::splat(0);
34
35 /// All ones.
36 pub const ONE: Self = Self::splat(1);
37
38 /// All `u32::MIN`.
39 pub const MIN: Self = Self::splat(u32::MIN);
40
41 /// All `u32::MAX`.
42 pub const MAX: Self = Self::splat(u32::MAX);
43
44 /// A unit vector pointing along the positive X axis.
45 pub const X: Self = Self::new(1, 0, 0, 0);
46
47 /// A unit vector pointing along the positive Y axis.
48 pub const Y: Self = Self::new(0, 1, 0, 0);
49
50 /// A unit vector pointing along the positive Z axis.
51 pub const Z: Self = Self::new(0, 0, 1, 0);
52
53 /// A unit vector pointing along the positive W axis.
54 pub const W: Self = Self::new(0, 0, 0, 1);
55
56 /// The unit axes.
57 pub const AXES: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W];
58
59 /// Creates a new vector.
60 #[inline(always)]
61 #[must_use]
new(x: u32, y: u32, z: u32, w: u32) -> Self62 pub const fn new(x: u32, y: u32, z: u32, w: u32) -> Self {
63 Self { x, y, z, w }
64 }
65
66 /// Creates a vector with all elements set to `v`.
67 #[inline]
68 #[must_use]
splat(v: u32) -> Self69 pub const fn splat(v: u32) -> Self {
70 Self {
71 x: v,
72
73 y: v,
74
75 z: v,
76
77 w: v,
78 }
79 }
80
81 /// Returns a vector containing each element of `self` modified by a mapping function `f`.
82 #[inline]
83 #[must_use]
map<F>(self, f: F) -> Self where F: Fn(u32) -> u32,84 pub fn map<F>(self, f: F) -> Self
85 where
86 F: Fn(u32) -> u32,
87 {
88 Self::new(f(self.x), f(self.y), f(self.z), f(self.w))
89 }
90
91 /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
92 /// for each element of `self`.
93 ///
94 /// A true element in the mask uses the corresponding element from `if_true`, and false
95 /// uses the element from `if_false`.
96 #[inline]
97 #[must_use]
select(mask: BVec4, if_true: Self, if_false: Self) -> Self98 pub fn select(mask: BVec4, if_true: Self, if_false: Self) -> Self {
99 Self {
100 x: if mask.test(0) { if_true.x } else { if_false.x },
101 y: if mask.test(1) { if_true.y } else { if_false.y },
102 z: if mask.test(2) { if_true.z } else { if_false.z },
103 w: if mask.test(3) { if_true.w } else { if_false.w },
104 }
105 }
106
107 /// Creates a new vector from an array.
108 #[inline]
109 #[must_use]
from_array(a: [u32; 4]) -> Self110 pub const fn from_array(a: [u32; 4]) -> Self {
111 Self::new(a[0], a[1], a[2], a[3])
112 }
113
114 /// `[x, y, z, w]`
115 #[inline]
116 #[must_use]
to_array(&self) -> [u32; 4]117 pub const fn to_array(&self) -> [u32; 4] {
118 [self.x, self.y, self.z, self.w]
119 }
120
121 /// Creates a vector from the first 4 values in `slice`.
122 ///
123 /// # Panics
124 ///
125 /// Panics if `slice` is less than 4 elements long.
126 #[inline]
127 #[must_use]
from_slice(slice: &[u32]) -> Self128 pub const fn from_slice(slice: &[u32]) -> Self {
129 assert!(slice.len() >= 4);
130 Self::new(slice[0], slice[1], slice[2], slice[3])
131 }
132
133 /// Writes the elements of `self` to the first 4 elements in `slice`.
134 ///
135 /// # Panics
136 ///
137 /// Panics if `slice` is less than 4 elements long.
138 #[inline]
write_to_slice(self, slice: &mut [u32])139 pub fn write_to_slice(self, slice: &mut [u32]) {
140 slice[..4].copy_from_slice(&self.to_array());
141 }
142
143 /// Creates a 3D vector from the `x`, `y` and `z` elements of `self`, discarding `w`.
144 ///
145 /// Truncation to [`UVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()].
146 #[inline]
147 #[must_use]
truncate(self) -> UVec3148 pub fn truncate(self) -> UVec3 {
149 use crate::swizzles::Vec4Swizzles;
150 self.xyz()
151 }
152
153 /// Creates a 4D vector from `self` with the given value of `x`.
154 #[inline]
155 #[must_use]
with_x(mut self, x: u32) -> Self156 pub fn with_x(mut self, x: u32) -> Self {
157 self.x = x;
158 self
159 }
160
161 /// Creates a 4D vector from `self` with the given value of `y`.
162 #[inline]
163 #[must_use]
with_y(mut self, y: u32) -> Self164 pub fn with_y(mut self, y: u32) -> Self {
165 self.y = y;
166 self
167 }
168
169 /// Creates a 4D vector from `self` with the given value of `z`.
170 #[inline]
171 #[must_use]
with_z(mut self, z: u32) -> Self172 pub fn with_z(mut self, z: u32) -> Self {
173 self.z = z;
174 self
175 }
176
177 /// Creates a 4D vector from `self` with the given value of `w`.
178 #[inline]
179 #[must_use]
with_w(mut self, w: u32) -> Self180 pub fn with_w(mut self, w: u32) -> Self {
181 self.w = w;
182 self
183 }
184
185 /// Computes the dot product of `self` and `rhs`.
186 #[inline]
187 #[must_use]
dot(self, rhs: Self) -> u32188 pub fn dot(self, rhs: Self) -> u32 {
189 (self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z) + (self.w * rhs.w)
190 }
191
192 /// Returns a vector where every component is the dot product of `self` and `rhs`.
193 #[inline]
194 #[must_use]
dot_into_vec(self, rhs: Self) -> Self195 pub fn dot_into_vec(self, rhs: Self) -> Self {
196 Self::splat(self.dot(rhs))
197 }
198
199 /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
200 ///
201 /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
202 #[inline]
203 #[must_use]
min(self, rhs: Self) -> Self204 pub fn min(self, rhs: Self) -> Self {
205 Self {
206 x: self.x.min(rhs.x),
207 y: self.y.min(rhs.y),
208 z: self.z.min(rhs.z),
209 w: self.w.min(rhs.w),
210 }
211 }
212
213 /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
214 ///
215 /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
216 #[inline]
217 #[must_use]
max(self, rhs: Self) -> Self218 pub fn max(self, rhs: Self) -> Self {
219 Self {
220 x: self.x.max(rhs.x),
221 y: self.y.max(rhs.y),
222 z: self.z.max(rhs.z),
223 w: self.w.max(rhs.w),
224 }
225 }
226
227 /// Component-wise clamping of values, similar to [`u32::clamp`].
228 ///
229 /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
230 ///
231 /// # Panics
232 ///
233 /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
234 #[inline]
235 #[must_use]
clamp(self, min: Self, max: Self) -> Self236 pub fn clamp(self, min: Self, max: Self) -> Self {
237 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
238 self.max(min).min(max)
239 }
240
241 /// Returns the horizontal minimum of `self`.
242 ///
243 /// In other words this computes `min(x, y, ..)`.
244 #[inline]
245 #[must_use]
min_element(self) -> u32246 pub fn min_element(self) -> u32 {
247 self.x.min(self.y.min(self.z.min(self.w)))
248 }
249
250 /// Returns the horizontal maximum of `self`.
251 ///
252 /// In other words this computes `max(x, y, ..)`.
253 #[inline]
254 #[must_use]
max_element(self) -> u32255 pub fn max_element(self) -> u32 {
256 self.x.max(self.y.max(self.z.max(self.w)))
257 }
258
259 /// Returns the sum of all elements of `self`.
260 ///
261 /// In other words, this computes `self.x + self.y + ..`.
262 #[inline]
263 #[must_use]
element_sum(self) -> u32264 pub fn element_sum(self) -> u32 {
265 self.x + self.y + self.z + self.w
266 }
267
268 /// Returns the product of all elements of `self`.
269 ///
270 /// In other words, this computes `self.x * self.y * ..`.
271 #[inline]
272 #[must_use]
element_product(self) -> u32273 pub fn element_product(self) -> u32 {
274 self.x * self.y * self.z * self.w
275 }
276
277 /// Returns a vector mask containing the result of a `==` comparison for each element of
278 /// `self` and `rhs`.
279 ///
280 /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
281 /// elements.
282 #[inline]
283 #[must_use]
cmpeq(self, rhs: Self) -> BVec4284 pub fn cmpeq(self, rhs: Self) -> BVec4 {
285 BVec4::new(
286 self.x.eq(&rhs.x),
287 self.y.eq(&rhs.y),
288 self.z.eq(&rhs.z),
289 self.w.eq(&rhs.w),
290 )
291 }
292
293 /// Returns a vector mask containing the result of a `!=` comparison for each element of
294 /// `self` and `rhs`.
295 ///
296 /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
297 /// elements.
298 #[inline]
299 #[must_use]
cmpne(self, rhs: Self) -> BVec4300 pub fn cmpne(self, rhs: Self) -> BVec4 {
301 BVec4::new(
302 self.x.ne(&rhs.x),
303 self.y.ne(&rhs.y),
304 self.z.ne(&rhs.z),
305 self.w.ne(&rhs.w),
306 )
307 }
308
309 /// Returns a vector mask containing the result of a `>=` comparison for each element of
310 /// `self` and `rhs`.
311 ///
312 /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
313 /// elements.
314 #[inline]
315 #[must_use]
cmpge(self, rhs: Self) -> BVec4316 pub fn cmpge(self, rhs: Self) -> BVec4 {
317 BVec4::new(
318 self.x.ge(&rhs.x),
319 self.y.ge(&rhs.y),
320 self.z.ge(&rhs.z),
321 self.w.ge(&rhs.w),
322 )
323 }
324
325 /// Returns a vector mask containing the result of a `>` comparison for each element of
326 /// `self` and `rhs`.
327 ///
328 /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
329 /// elements.
330 #[inline]
331 #[must_use]
cmpgt(self, rhs: Self) -> BVec4332 pub fn cmpgt(self, rhs: Self) -> BVec4 {
333 BVec4::new(
334 self.x.gt(&rhs.x),
335 self.y.gt(&rhs.y),
336 self.z.gt(&rhs.z),
337 self.w.gt(&rhs.w),
338 )
339 }
340
341 /// Returns a vector mask containing the result of a `<=` comparison for each element of
342 /// `self` and `rhs`.
343 ///
344 /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
345 /// elements.
346 #[inline]
347 #[must_use]
cmple(self, rhs: Self) -> BVec4348 pub fn cmple(self, rhs: Self) -> BVec4 {
349 BVec4::new(
350 self.x.le(&rhs.x),
351 self.y.le(&rhs.y),
352 self.z.le(&rhs.z),
353 self.w.le(&rhs.w),
354 )
355 }
356
357 /// Returns a vector mask containing the result of a `<` comparison for each element of
358 /// `self` and `rhs`.
359 ///
360 /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
361 /// elements.
362 #[inline]
363 #[must_use]
cmplt(self, rhs: Self) -> BVec4364 pub fn cmplt(self, rhs: Self) -> BVec4 {
365 BVec4::new(
366 self.x.lt(&rhs.x),
367 self.y.lt(&rhs.y),
368 self.z.lt(&rhs.z),
369 self.w.lt(&rhs.w),
370 )
371 }
372
373 /// Computes the squared length of `self`.
374 #[doc(alias = "magnitude2")]
375 #[inline]
376 #[must_use]
length_squared(self) -> u32377 pub fn length_squared(self) -> u32 {
378 self.dot(self)
379 }
380
381 /// Computes the [manhattan distance] between two points.
382 ///
383 /// # Overflow
384 /// This method may overflow if the result is greater than [`u32::MAX`].
385 ///
386 /// See also [`checked_manhattan_distance`][UVec4::checked_manhattan_distance].
387 ///
388 /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
389 #[inline]
390 #[must_use]
manhattan_distance(self, other: Self) -> u32391 pub fn manhattan_distance(self, other: Self) -> u32 {
392 self.x.abs_diff(other.x)
393 + self.y.abs_diff(other.y)
394 + self.z.abs_diff(other.z)
395 + self.w.abs_diff(other.w)
396 }
397
398 /// Computes the [manhattan distance] between two points.
399 ///
400 /// This will returns [`None`] if the result is greater than [`u32::MAX`].
401 ///
402 /// [manhattan distance]: https://en.wikipedia.org/wiki/Taxicab_geometry
403 #[inline]
404 #[must_use]
checked_manhattan_distance(self, other: Self) -> Option<u32>405 pub fn checked_manhattan_distance(self, other: Self) -> Option<u32> {
406 let d = self.x.abs_diff(other.x);
407 let d = d.checked_add(self.y.abs_diff(other.y))?;
408 let d = d.checked_add(self.z.abs_diff(other.z))?;
409 d.checked_add(self.w.abs_diff(other.w))
410 }
411
412 /// Computes the [chebyshev distance] between two points.
413 ///
414 /// [chebyshev distance]: https://en.wikipedia.org/wiki/Chebyshev_distance
415 #[inline]
416 #[must_use]
chebyshev_distance(self, other: Self) -> u32417 pub fn chebyshev_distance(self, other: Self) -> u32 {
418 // Note: the compiler will eventually optimize out the loop
419 [
420 self.x.abs_diff(other.x),
421 self.y.abs_diff(other.y),
422 self.z.abs_diff(other.z),
423 self.w.abs_diff(other.w),
424 ]
425 .into_iter()
426 .max()
427 .unwrap()
428 }
429
430 /// Casts all elements of `self` to `f32`.
431 #[inline]
432 #[must_use]
as_vec4(&self) -> crate::Vec4433 pub fn as_vec4(&self) -> crate::Vec4 {
434 crate::Vec4::new(self.x as f32, self.y as f32, self.z as f32, self.w as f32)
435 }
436
437 /// Casts all elements of `self` to `f64`.
438 #[inline]
439 #[must_use]
as_dvec4(&self) -> crate::DVec4440 pub fn as_dvec4(&self) -> crate::DVec4 {
441 crate::DVec4::new(self.x as f64, self.y as f64, self.z as f64, self.w as f64)
442 }
443
444 /// Casts all elements of `self` to `i8`.
445 #[inline]
446 #[must_use]
as_i8vec4(&self) -> crate::I8Vec4447 pub fn as_i8vec4(&self) -> crate::I8Vec4 {
448 crate::I8Vec4::new(self.x as i8, self.y as i8, self.z as i8, self.w as i8)
449 }
450
451 /// Casts all elements of `self` to `u8`.
452 #[inline]
453 #[must_use]
as_u8vec4(&self) -> crate::U8Vec4454 pub fn as_u8vec4(&self) -> crate::U8Vec4 {
455 crate::U8Vec4::new(self.x as u8, self.y as u8, self.z as u8, self.w as u8)
456 }
457
458 /// Casts all elements of `self` to `i16`.
459 #[inline]
460 #[must_use]
as_i16vec4(&self) -> crate::I16Vec4461 pub fn as_i16vec4(&self) -> crate::I16Vec4 {
462 crate::I16Vec4::new(self.x as i16, self.y as i16, self.z as i16, self.w as i16)
463 }
464
465 /// Casts all elements of `self` to `u16`.
466 #[inline]
467 #[must_use]
as_u16vec4(&self) -> crate::U16Vec4468 pub fn as_u16vec4(&self) -> crate::U16Vec4 {
469 crate::U16Vec4::new(self.x as u16, self.y as u16, self.z as u16, self.w as u16)
470 }
471
472 /// Casts all elements of `self` to `i32`.
473 #[inline]
474 #[must_use]
as_ivec4(&self) -> crate::IVec4475 pub fn as_ivec4(&self) -> crate::IVec4 {
476 crate::IVec4::new(self.x as i32, self.y as i32, self.z as i32, self.w as i32)
477 }
478
479 /// Casts all elements of `self` to `i64`.
480 #[inline]
481 #[must_use]
as_i64vec4(&self) -> crate::I64Vec4482 pub fn as_i64vec4(&self) -> crate::I64Vec4 {
483 crate::I64Vec4::new(self.x as i64, self.y as i64, self.z as i64, self.w as i64)
484 }
485
486 /// Casts all elements of `self` to `u64`.
487 #[inline]
488 #[must_use]
as_u64vec4(&self) -> crate::U64Vec4489 pub fn as_u64vec4(&self) -> crate::U64Vec4 {
490 crate::U64Vec4::new(self.x as u64, self.y as u64, self.z as u64, self.w as u64)
491 }
492
493 /// Returns a vector containing the wrapping addition of `self` and `rhs`.
494 ///
495 /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
496 #[inline]
497 #[must_use]
checked_add(self, rhs: Self) -> Option<Self>498 pub const fn checked_add(self, rhs: Self) -> Option<Self> {
499 let x = match self.x.checked_add(rhs.x) {
500 Some(v) => v,
501 None => return None,
502 };
503 let y = match self.y.checked_add(rhs.y) {
504 Some(v) => v,
505 None => return None,
506 };
507 let z = match self.z.checked_add(rhs.z) {
508 Some(v) => v,
509 None => return None,
510 };
511 let w = match self.w.checked_add(rhs.w) {
512 Some(v) => v,
513 None => return None,
514 };
515
516 Some(Self { x, y, z, w })
517 }
518
519 /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
520 ///
521 /// In other words this computes `Some([self.x - rhs.x, self.y - rhs.y, ..])` but returns `None` on any overflow.
522 #[inline]
523 #[must_use]
checked_sub(self, rhs: Self) -> Option<Self>524 pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
525 let x = match self.x.checked_sub(rhs.x) {
526 Some(v) => v,
527 None => return None,
528 };
529 let y = match self.y.checked_sub(rhs.y) {
530 Some(v) => v,
531 None => return None,
532 };
533 let z = match self.z.checked_sub(rhs.z) {
534 Some(v) => v,
535 None => return None,
536 };
537 let w = match self.w.checked_sub(rhs.w) {
538 Some(v) => v,
539 None => return None,
540 };
541
542 Some(Self { x, y, z, w })
543 }
544
545 /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
546 ///
547 /// In other words this computes `Some([self.x * rhs.x, self.y * rhs.y, ..])` but returns `None` on any overflow.
548 #[inline]
549 #[must_use]
checked_mul(self, rhs: Self) -> Option<Self>550 pub const fn checked_mul(self, rhs: Self) -> Option<Self> {
551 let x = match self.x.checked_mul(rhs.x) {
552 Some(v) => v,
553 None => return None,
554 };
555 let y = match self.y.checked_mul(rhs.y) {
556 Some(v) => v,
557 None => return None,
558 };
559 let z = match self.z.checked_mul(rhs.z) {
560 Some(v) => v,
561 None => return None,
562 };
563 let w = match self.w.checked_mul(rhs.w) {
564 Some(v) => v,
565 None => return None,
566 };
567
568 Some(Self { x, y, z, w })
569 }
570
571 /// Returns a vector containing the wrapping division of `self` and `rhs`.
572 ///
573 /// In other words this computes `Some([self.x / rhs.x, self.y / rhs.y, ..])` but returns `None` on any division by zero.
574 #[inline]
575 #[must_use]
checked_div(self, rhs: Self) -> Option<Self>576 pub const fn checked_div(self, rhs: Self) -> Option<Self> {
577 let x = match self.x.checked_div(rhs.x) {
578 Some(v) => v,
579 None => return None,
580 };
581 let y = match self.y.checked_div(rhs.y) {
582 Some(v) => v,
583 None => return None,
584 };
585 let z = match self.z.checked_div(rhs.z) {
586 Some(v) => v,
587 None => return None,
588 };
589 let w = match self.w.checked_div(rhs.w) {
590 Some(v) => v,
591 None => return None,
592 };
593
594 Some(Self { x, y, z, w })
595 }
596
597 /// Returns a vector containing the wrapping addition of `self` and `rhs`.
598 ///
599 /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
600 #[inline]
601 #[must_use]
wrapping_add(self, rhs: Self) -> Self602 pub const fn wrapping_add(self, rhs: Self) -> Self {
603 Self {
604 x: self.x.wrapping_add(rhs.x),
605 y: self.y.wrapping_add(rhs.y),
606 z: self.z.wrapping_add(rhs.z),
607 w: self.w.wrapping_add(rhs.w),
608 }
609 }
610
611 /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
612 ///
613 /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
614 #[inline]
615 #[must_use]
wrapping_sub(self, rhs: Self) -> Self616 pub const fn wrapping_sub(self, rhs: Self) -> Self {
617 Self {
618 x: self.x.wrapping_sub(rhs.x),
619 y: self.y.wrapping_sub(rhs.y),
620 z: self.z.wrapping_sub(rhs.z),
621 w: self.w.wrapping_sub(rhs.w),
622 }
623 }
624
625 /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
626 ///
627 /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
628 #[inline]
629 #[must_use]
wrapping_mul(self, rhs: Self) -> Self630 pub const fn wrapping_mul(self, rhs: Self) -> Self {
631 Self {
632 x: self.x.wrapping_mul(rhs.x),
633 y: self.y.wrapping_mul(rhs.y),
634 z: self.z.wrapping_mul(rhs.z),
635 w: self.w.wrapping_mul(rhs.w),
636 }
637 }
638
639 /// Returns a vector containing the wrapping division of `self` and `rhs`.
640 ///
641 /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
642 #[inline]
643 #[must_use]
wrapping_div(self, rhs: Self) -> Self644 pub const fn wrapping_div(self, rhs: Self) -> Self {
645 Self {
646 x: self.x.wrapping_div(rhs.x),
647 y: self.y.wrapping_div(rhs.y),
648 z: self.z.wrapping_div(rhs.z),
649 w: self.w.wrapping_div(rhs.w),
650 }
651 }
652
653 /// Returns a vector containing the saturating addition of `self` and `rhs`.
654 ///
655 /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
656 #[inline]
657 #[must_use]
saturating_add(self, rhs: Self) -> Self658 pub const fn saturating_add(self, rhs: Self) -> Self {
659 Self {
660 x: self.x.saturating_add(rhs.x),
661 y: self.y.saturating_add(rhs.y),
662 z: self.z.saturating_add(rhs.z),
663 w: self.w.saturating_add(rhs.w),
664 }
665 }
666
667 /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
668 ///
669 /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
670 #[inline]
671 #[must_use]
saturating_sub(self, rhs: Self) -> Self672 pub const fn saturating_sub(self, rhs: Self) -> Self {
673 Self {
674 x: self.x.saturating_sub(rhs.x),
675 y: self.y.saturating_sub(rhs.y),
676 z: self.z.saturating_sub(rhs.z),
677 w: self.w.saturating_sub(rhs.w),
678 }
679 }
680
681 /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
682 ///
683 /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
684 #[inline]
685 #[must_use]
saturating_mul(self, rhs: Self) -> Self686 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 w: self.w.saturating_mul(rhs.w),
692 }
693 }
694
695 /// Returns a vector containing the saturating division of `self` and `rhs`.
696 ///
697 /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
698 #[inline]
699 #[must_use]
saturating_div(self, rhs: Self) -> Self700 pub const fn saturating_div(self, rhs: Self) -> Self {
701 Self {
702 x: self.x.saturating_div(rhs.x),
703 y: self.y.saturating_div(rhs.y),
704 z: self.z.saturating_div(rhs.z),
705 w: self.w.saturating_div(rhs.w),
706 }
707 }
708
709 /// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`.
710 ///
711 /// In other words this computes `Some([self.x + rhs.x, self.y + rhs.y, ..])` but returns `None` on any overflow.
712 #[inline]
713 #[must_use]
checked_add_signed(self, rhs: IVec4) -> Option<Self>714 pub const fn checked_add_signed(self, rhs: IVec4) -> Option<Self> {
715 let x = match self.x.checked_add_signed(rhs.x) {
716 Some(v) => v,
717 None => return None,
718 };
719 let y = match self.y.checked_add_signed(rhs.y) {
720 Some(v) => v,
721 None => return None,
722 };
723 let z = match self.z.checked_add_signed(rhs.z) {
724 Some(v) => v,
725 None => return None,
726 };
727 let w = match self.w.checked_add_signed(rhs.w) {
728 Some(v) => v,
729 None => return None,
730 };
731
732 Some(Self { x, y, z, w })
733 }
734
735 /// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`.
736 ///
737 /// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`.
738 #[inline]
739 #[must_use]
wrapping_add_signed(self, rhs: IVec4) -> Self740 pub const fn wrapping_add_signed(self, rhs: IVec4) -> Self {
741 Self {
742 x: self.x.wrapping_add_signed(rhs.x),
743 y: self.y.wrapping_add_signed(rhs.y),
744 z: self.z.wrapping_add_signed(rhs.z),
745 w: self.w.wrapping_add_signed(rhs.w),
746 }
747 }
748
749 /// Returns a vector containing the saturating addition of `self` and signed vector `rhs`.
750 ///
751 /// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`.
752 #[inline]
753 #[must_use]
saturating_add_signed(self, rhs: IVec4) -> Self754 pub const fn saturating_add_signed(self, rhs: IVec4) -> Self {
755 Self {
756 x: self.x.saturating_add_signed(rhs.x),
757 y: self.y.saturating_add_signed(rhs.y),
758 z: self.z.saturating_add_signed(rhs.z),
759 w: self.w.saturating_add_signed(rhs.w),
760 }
761 }
762 }
763
764 impl Default for UVec4 {
765 #[inline(always)]
default() -> Self766 fn default() -> Self {
767 Self::ZERO
768 }
769 }
770
771 impl Div<UVec4> for UVec4 {
772 type Output = Self;
773 #[inline]
div(self, rhs: Self) -> Self774 fn div(self, rhs: Self) -> Self {
775 Self {
776 x: self.x.div(rhs.x),
777 y: self.y.div(rhs.y),
778 z: self.z.div(rhs.z),
779 w: self.w.div(rhs.w),
780 }
781 }
782 }
783
784 impl Div<&UVec4> for UVec4 {
785 type Output = UVec4;
786 #[inline]
div(self, rhs: &UVec4) -> UVec4787 fn div(self, rhs: &UVec4) -> UVec4 {
788 self.div(*rhs)
789 }
790 }
791
792 impl Div<&UVec4> for &UVec4 {
793 type Output = UVec4;
794 #[inline]
div(self, rhs: &UVec4) -> UVec4795 fn div(self, rhs: &UVec4) -> UVec4 {
796 (*self).div(*rhs)
797 }
798 }
799
800 impl Div<UVec4> for &UVec4 {
801 type Output = UVec4;
802 #[inline]
div(self, rhs: UVec4) -> UVec4803 fn div(self, rhs: UVec4) -> UVec4 {
804 (*self).div(rhs)
805 }
806 }
807
808 impl DivAssign<UVec4> for UVec4 {
809 #[inline]
div_assign(&mut self, rhs: Self)810 fn div_assign(&mut self, rhs: Self) {
811 self.x.div_assign(rhs.x);
812 self.y.div_assign(rhs.y);
813 self.z.div_assign(rhs.z);
814 self.w.div_assign(rhs.w);
815 }
816 }
817
818 impl DivAssign<&UVec4> for UVec4 {
819 #[inline]
div_assign(&mut self, rhs: &UVec4)820 fn div_assign(&mut self, rhs: &UVec4) {
821 self.div_assign(*rhs)
822 }
823 }
824
825 impl Div<u32> for UVec4 {
826 type Output = Self;
827 #[inline]
div(self, rhs: u32) -> Self828 fn div(self, rhs: u32) -> Self {
829 Self {
830 x: self.x.div(rhs),
831 y: self.y.div(rhs),
832 z: self.z.div(rhs),
833 w: self.w.div(rhs),
834 }
835 }
836 }
837
838 impl Div<&u32> for UVec4 {
839 type Output = UVec4;
840 #[inline]
div(self, rhs: &u32) -> UVec4841 fn div(self, rhs: &u32) -> UVec4 {
842 self.div(*rhs)
843 }
844 }
845
846 impl Div<&u32> for &UVec4 {
847 type Output = UVec4;
848 #[inline]
div(self, rhs: &u32) -> UVec4849 fn div(self, rhs: &u32) -> UVec4 {
850 (*self).div(*rhs)
851 }
852 }
853
854 impl Div<u32> for &UVec4 {
855 type Output = UVec4;
856 #[inline]
div(self, rhs: u32) -> UVec4857 fn div(self, rhs: u32) -> UVec4 {
858 (*self).div(rhs)
859 }
860 }
861
862 impl DivAssign<u32> for UVec4 {
863 #[inline]
div_assign(&mut self, rhs: u32)864 fn div_assign(&mut self, rhs: u32) {
865 self.x.div_assign(rhs);
866 self.y.div_assign(rhs);
867 self.z.div_assign(rhs);
868 self.w.div_assign(rhs);
869 }
870 }
871
872 impl DivAssign<&u32> for UVec4 {
873 #[inline]
div_assign(&mut self, rhs: &u32)874 fn div_assign(&mut self, rhs: &u32) {
875 self.div_assign(*rhs)
876 }
877 }
878
879 impl Div<UVec4> for u32 {
880 type Output = UVec4;
881 #[inline]
div(self, rhs: UVec4) -> UVec4882 fn div(self, rhs: UVec4) -> UVec4 {
883 UVec4 {
884 x: self.div(rhs.x),
885 y: self.div(rhs.y),
886 z: self.div(rhs.z),
887 w: self.div(rhs.w),
888 }
889 }
890 }
891
892 impl Div<&UVec4> for u32 {
893 type Output = UVec4;
894 #[inline]
div(self, rhs: &UVec4) -> UVec4895 fn div(self, rhs: &UVec4) -> UVec4 {
896 self.div(*rhs)
897 }
898 }
899
900 impl Div<&UVec4> for &u32 {
901 type Output = UVec4;
902 #[inline]
div(self, rhs: &UVec4) -> UVec4903 fn div(self, rhs: &UVec4) -> UVec4 {
904 (*self).div(*rhs)
905 }
906 }
907
908 impl Div<UVec4> for &u32 {
909 type Output = UVec4;
910 #[inline]
div(self, rhs: UVec4) -> UVec4911 fn div(self, rhs: UVec4) -> UVec4 {
912 (*self).div(rhs)
913 }
914 }
915
916 impl Mul<UVec4> for UVec4 {
917 type Output = Self;
918 #[inline]
mul(self, rhs: Self) -> Self919 fn mul(self, rhs: Self) -> Self {
920 Self {
921 x: self.x.mul(rhs.x),
922 y: self.y.mul(rhs.y),
923 z: self.z.mul(rhs.z),
924 w: self.w.mul(rhs.w),
925 }
926 }
927 }
928
929 impl Mul<&UVec4> for UVec4 {
930 type Output = UVec4;
931 #[inline]
mul(self, rhs: &UVec4) -> UVec4932 fn mul(self, rhs: &UVec4) -> UVec4 {
933 self.mul(*rhs)
934 }
935 }
936
937 impl Mul<&UVec4> for &UVec4 {
938 type Output = UVec4;
939 #[inline]
mul(self, rhs: &UVec4) -> UVec4940 fn mul(self, rhs: &UVec4) -> UVec4 {
941 (*self).mul(*rhs)
942 }
943 }
944
945 impl Mul<UVec4> for &UVec4 {
946 type Output = UVec4;
947 #[inline]
mul(self, rhs: UVec4) -> UVec4948 fn mul(self, rhs: UVec4) -> UVec4 {
949 (*self).mul(rhs)
950 }
951 }
952
953 impl MulAssign<UVec4> for UVec4 {
954 #[inline]
mul_assign(&mut self, rhs: Self)955 fn mul_assign(&mut self, rhs: Self) {
956 self.x.mul_assign(rhs.x);
957 self.y.mul_assign(rhs.y);
958 self.z.mul_assign(rhs.z);
959 self.w.mul_assign(rhs.w);
960 }
961 }
962
963 impl MulAssign<&UVec4> for UVec4 {
964 #[inline]
mul_assign(&mut self, rhs: &UVec4)965 fn mul_assign(&mut self, rhs: &UVec4) {
966 self.mul_assign(*rhs)
967 }
968 }
969
970 impl Mul<u32> for UVec4 {
971 type Output = Self;
972 #[inline]
mul(self, rhs: u32) -> Self973 fn mul(self, rhs: u32) -> Self {
974 Self {
975 x: self.x.mul(rhs),
976 y: self.y.mul(rhs),
977 z: self.z.mul(rhs),
978 w: self.w.mul(rhs),
979 }
980 }
981 }
982
983 impl Mul<&u32> for UVec4 {
984 type Output = UVec4;
985 #[inline]
mul(self, rhs: &u32) -> UVec4986 fn mul(self, rhs: &u32) -> UVec4 {
987 self.mul(*rhs)
988 }
989 }
990
991 impl Mul<&u32> for &UVec4 {
992 type Output = UVec4;
993 #[inline]
mul(self, rhs: &u32) -> UVec4994 fn mul(self, rhs: &u32) -> UVec4 {
995 (*self).mul(*rhs)
996 }
997 }
998
999 impl Mul<u32> for &UVec4 {
1000 type Output = UVec4;
1001 #[inline]
mul(self, rhs: u32) -> UVec41002 fn mul(self, rhs: u32) -> UVec4 {
1003 (*self).mul(rhs)
1004 }
1005 }
1006
1007 impl MulAssign<u32> for UVec4 {
1008 #[inline]
mul_assign(&mut self, rhs: u32)1009 fn mul_assign(&mut self, rhs: u32) {
1010 self.x.mul_assign(rhs);
1011 self.y.mul_assign(rhs);
1012 self.z.mul_assign(rhs);
1013 self.w.mul_assign(rhs);
1014 }
1015 }
1016
1017 impl MulAssign<&u32> for UVec4 {
1018 #[inline]
mul_assign(&mut self, rhs: &u32)1019 fn mul_assign(&mut self, rhs: &u32) {
1020 self.mul_assign(*rhs)
1021 }
1022 }
1023
1024 impl Mul<UVec4> for u32 {
1025 type Output = UVec4;
1026 #[inline]
mul(self, rhs: UVec4) -> UVec41027 fn mul(self, rhs: UVec4) -> UVec4 {
1028 UVec4 {
1029 x: self.mul(rhs.x),
1030 y: self.mul(rhs.y),
1031 z: self.mul(rhs.z),
1032 w: self.mul(rhs.w),
1033 }
1034 }
1035 }
1036
1037 impl Mul<&UVec4> for u32 {
1038 type Output = UVec4;
1039 #[inline]
mul(self, rhs: &UVec4) -> UVec41040 fn mul(self, rhs: &UVec4) -> UVec4 {
1041 self.mul(*rhs)
1042 }
1043 }
1044
1045 impl Mul<&UVec4> for &u32 {
1046 type Output = UVec4;
1047 #[inline]
mul(self, rhs: &UVec4) -> UVec41048 fn mul(self, rhs: &UVec4) -> UVec4 {
1049 (*self).mul(*rhs)
1050 }
1051 }
1052
1053 impl Mul<UVec4> for &u32 {
1054 type Output = UVec4;
1055 #[inline]
mul(self, rhs: UVec4) -> UVec41056 fn mul(self, rhs: UVec4) -> UVec4 {
1057 (*self).mul(rhs)
1058 }
1059 }
1060
1061 impl Add<UVec4> for UVec4 {
1062 type Output = Self;
1063 #[inline]
add(self, rhs: Self) -> Self1064 fn add(self, rhs: Self) -> Self {
1065 Self {
1066 x: self.x.add(rhs.x),
1067 y: self.y.add(rhs.y),
1068 z: self.z.add(rhs.z),
1069 w: self.w.add(rhs.w),
1070 }
1071 }
1072 }
1073
1074 impl Add<&UVec4> for UVec4 {
1075 type Output = UVec4;
1076 #[inline]
add(self, rhs: &UVec4) -> UVec41077 fn add(self, rhs: &UVec4) -> UVec4 {
1078 self.add(*rhs)
1079 }
1080 }
1081
1082 impl Add<&UVec4> for &UVec4 {
1083 type Output = UVec4;
1084 #[inline]
add(self, rhs: &UVec4) -> UVec41085 fn add(self, rhs: &UVec4) -> UVec4 {
1086 (*self).add(*rhs)
1087 }
1088 }
1089
1090 impl Add<UVec4> for &UVec4 {
1091 type Output = UVec4;
1092 #[inline]
add(self, rhs: UVec4) -> UVec41093 fn add(self, rhs: UVec4) -> UVec4 {
1094 (*self).add(rhs)
1095 }
1096 }
1097
1098 impl AddAssign<UVec4> for UVec4 {
1099 #[inline]
add_assign(&mut self, rhs: Self)1100 fn add_assign(&mut self, rhs: Self) {
1101 self.x.add_assign(rhs.x);
1102 self.y.add_assign(rhs.y);
1103 self.z.add_assign(rhs.z);
1104 self.w.add_assign(rhs.w);
1105 }
1106 }
1107
1108 impl AddAssign<&UVec4> for UVec4 {
1109 #[inline]
add_assign(&mut self, rhs: &UVec4)1110 fn add_assign(&mut self, rhs: &UVec4) {
1111 self.add_assign(*rhs)
1112 }
1113 }
1114
1115 impl Add<u32> for UVec4 {
1116 type Output = Self;
1117 #[inline]
add(self, rhs: u32) -> Self1118 fn add(self, rhs: u32) -> Self {
1119 Self {
1120 x: self.x.add(rhs),
1121 y: self.y.add(rhs),
1122 z: self.z.add(rhs),
1123 w: self.w.add(rhs),
1124 }
1125 }
1126 }
1127
1128 impl Add<&u32> for UVec4 {
1129 type Output = UVec4;
1130 #[inline]
add(self, rhs: &u32) -> UVec41131 fn add(self, rhs: &u32) -> UVec4 {
1132 self.add(*rhs)
1133 }
1134 }
1135
1136 impl Add<&u32> for &UVec4 {
1137 type Output = UVec4;
1138 #[inline]
add(self, rhs: &u32) -> UVec41139 fn add(self, rhs: &u32) -> UVec4 {
1140 (*self).add(*rhs)
1141 }
1142 }
1143
1144 impl Add<u32> for &UVec4 {
1145 type Output = UVec4;
1146 #[inline]
add(self, rhs: u32) -> UVec41147 fn add(self, rhs: u32) -> UVec4 {
1148 (*self).add(rhs)
1149 }
1150 }
1151
1152 impl AddAssign<u32> for UVec4 {
1153 #[inline]
add_assign(&mut self, rhs: u32)1154 fn add_assign(&mut self, rhs: u32) {
1155 self.x.add_assign(rhs);
1156 self.y.add_assign(rhs);
1157 self.z.add_assign(rhs);
1158 self.w.add_assign(rhs);
1159 }
1160 }
1161
1162 impl AddAssign<&u32> for UVec4 {
1163 #[inline]
add_assign(&mut self, rhs: &u32)1164 fn add_assign(&mut self, rhs: &u32) {
1165 self.add_assign(*rhs)
1166 }
1167 }
1168
1169 impl Add<UVec4> for u32 {
1170 type Output = UVec4;
1171 #[inline]
add(self, rhs: UVec4) -> UVec41172 fn add(self, rhs: UVec4) -> UVec4 {
1173 UVec4 {
1174 x: self.add(rhs.x),
1175 y: self.add(rhs.y),
1176 z: self.add(rhs.z),
1177 w: self.add(rhs.w),
1178 }
1179 }
1180 }
1181
1182 impl Add<&UVec4> for u32 {
1183 type Output = UVec4;
1184 #[inline]
add(self, rhs: &UVec4) -> UVec41185 fn add(self, rhs: &UVec4) -> UVec4 {
1186 self.add(*rhs)
1187 }
1188 }
1189
1190 impl Add<&UVec4> for &u32 {
1191 type Output = UVec4;
1192 #[inline]
add(self, rhs: &UVec4) -> UVec41193 fn add(self, rhs: &UVec4) -> UVec4 {
1194 (*self).add(*rhs)
1195 }
1196 }
1197
1198 impl Add<UVec4> for &u32 {
1199 type Output = UVec4;
1200 #[inline]
add(self, rhs: UVec4) -> UVec41201 fn add(self, rhs: UVec4) -> UVec4 {
1202 (*self).add(rhs)
1203 }
1204 }
1205
1206 impl Sub<UVec4> for UVec4 {
1207 type Output = Self;
1208 #[inline]
sub(self, rhs: Self) -> Self1209 fn sub(self, rhs: Self) -> Self {
1210 Self {
1211 x: self.x.sub(rhs.x),
1212 y: self.y.sub(rhs.y),
1213 z: self.z.sub(rhs.z),
1214 w: self.w.sub(rhs.w),
1215 }
1216 }
1217 }
1218
1219 impl Sub<&UVec4> for UVec4 {
1220 type Output = UVec4;
1221 #[inline]
sub(self, rhs: &UVec4) -> UVec41222 fn sub(self, rhs: &UVec4) -> UVec4 {
1223 self.sub(*rhs)
1224 }
1225 }
1226
1227 impl Sub<&UVec4> for &UVec4 {
1228 type Output = UVec4;
1229 #[inline]
sub(self, rhs: &UVec4) -> UVec41230 fn sub(self, rhs: &UVec4) -> UVec4 {
1231 (*self).sub(*rhs)
1232 }
1233 }
1234
1235 impl Sub<UVec4> for &UVec4 {
1236 type Output = UVec4;
1237 #[inline]
sub(self, rhs: UVec4) -> UVec41238 fn sub(self, rhs: UVec4) -> UVec4 {
1239 (*self).sub(rhs)
1240 }
1241 }
1242
1243 impl SubAssign<UVec4> for UVec4 {
1244 #[inline]
sub_assign(&mut self, rhs: UVec4)1245 fn sub_assign(&mut self, rhs: UVec4) {
1246 self.x.sub_assign(rhs.x);
1247 self.y.sub_assign(rhs.y);
1248 self.z.sub_assign(rhs.z);
1249 self.w.sub_assign(rhs.w);
1250 }
1251 }
1252
1253 impl SubAssign<&UVec4> for UVec4 {
1254 #[inline]
sub_assign(&mut self, rhs: &UVec4)1255 fn sub_assign(&mut self, rhs: &UVec4) {
1256 self.sub_assign(*rhs)
1257 }
1258 }
1259
1260 impl Sub<u32> for UVec4 {
1261 type Output = Self;
1262 #[inline]
sub(self, rhs: u32) -> Self1263 fn sub(self, rhs: u32) -> Self {
1264 Self {
1265 x: self.x.sub(rhs),
1266 y: self.y.sub(rhs),
1267 z: self.z.sub(rhs),
1268 w: self.w.sub(rhs),
1269 }
1270 }
1271 }
1272
1273 impl Sub<&u32> for UVec4 {
1274 type Output = UVec4;
1275 #[inline]
sub(self, rhs: &u32) -> UVec41276 fn sub(self, rhs: &u32) -> UVec4 {
1277 self.sub(*rhs)
1278 }
1279 }
1280
1281 impl Sub<&u32> for &UVec4 {
1282 type Output = UVec4;
1283 #[inline]
sub(self, rhs: &u32) -> UVec41284 fn sub(self, rhs: &u32) -> UVec4 {
1285 (*self).sub(*rhs)
1286 }
1287 }
1288
1289 impl Sub<u32> for &UVec4 {
1290 type Output = UVec4;
1291 #[inline]
sub(self, rhs: u32) -> UVec41292 fn sub(self, rhs: u32) -> UVec4 {
1293 (*self).sub(rhs)
1294 }
1295 }
1296
1297 impl SubAssign<u32> for UVec4 {
1298 #[inline]
sub_assign(&mut self, rhs: u32)1299 fn sub_assign(&mut self, rhs: u32) {
1300 self.x.sub_assign(rhs);
1301 self.y.sub_assign(rhs);
1302 self.z.sub_assign(rhs);
1303 self.w.sub_assign(rhs);
1304 }
1305 }
1306
1307 impl SubAssign<&u32> for UVec4 {
1308 #[inline]
sub_assign(&mut self, rhs: &u32)1309 fn sub_assign(&mut self, rhs: &u32) {
1310 self.sub_assign(*rhs)
1311 }
1312 }
1313
1314 impl Sub<UVec4> for u32 {
1315 type Output = UVec4;
1316 #[inline]
sub(self, rhs: UVec4) -> UVec41317 fn sub(self, rhs: UVec4) -> UVec4 {
1318 UVec4 {
1319 x: self.sub(rhs.x),
1320 y: self.sub(rhs.y),
1321 z: self.sub(rhs.z),
1322 w: self.sub(rhs.w),
1323 }
1324 }
1325 }
1326
1327 impl Sub<&UVec4> for u32 {
1328 type Output = UVec4;
1329 #[inline]
sub(self, rhs: &UVec4) -> UVec41330 fn sub(self, rhs: &UVec4) -> UVec4 {
1331 self.sub(*rhs)
1332 }
1333 }
1334
1335 impl Sub<&UVec4> for &u32 {
1336 type Output = UVec4;
1337 #[inline]
sub(self, rhs: &UVec4) -> UVec41338 fn sub(self, rhs: &UVec4) -> UVec4 {
1339 (*self).sub(*rhs)
1340 }
1341 }
1342
1343 impl Sub<UVec4> for &u32 {
1344 type Output = UVec4;
1345 #[inline]
sub(self, rhs: UVec4) -> UVec41346 fn sub(self, rhs: UVec4) -> UVec4 {
1347 (*self).sub(rhs)
1348 }
1349 }
1350
1351 impl Rem<UVec4> for UVec4 {
1352 type Output = Self;
1353 #[inline]
rem(self, rhs: Self) -> Self1354 fn rem(self, rhs: Self) -> Self {
1355 Self {
1356 x: self.x.rem(rhs.x),
1357 y: self.y.rem(rhs.y),
1358 z: self.z.rem(rhs.z),
1359 w: self.w.rem(rhs.w),
1360 }
1361 }
1362 }
1363
1364 impl Rem<&UVec4> for UVec4 {
1365 type Output = UVec4;
1366 #[inline]
rem(self, rhs: &UVec4) -> UVec41367 fn rem(self, rhs: &UVec4) -> UVec4 {
1368 self.rem(*rhs)
1369 }
1370 }
1371
1372 impl Rem<&UVec4> for &UVec4 {
1373 type Output = UVec4;
1374 #[inline]
rem(self, rhs: &UVec4) -> UVec41375 fn rem(self, rhs: &UVec4) -> UVec4 {
1376 (*self).rem(*rhs)
1377 }
1378 }
1379
1380 impl Rem<UVec4> for &UVec4 {
1381 type Output = UVec4;
1382 #[inline]
rem(self, rhs: UVec4) -> UVec41383 fn rem(self, rhs: UVec4) -> UVec4 {
1384 (*self).rem(rhs)
1385 }
1386 }
1387
1388 impl RemAssign<UVec4> for UVec4 {
1389 #[inline]
rem_assign(&mut self, rhs: Self)1390 fn rem_assign(&mut self, rhs: Self) {
1391 self.x.rem_assign(rhs.x);
1392 self.y.rem_assign(rhs.y);
1393 self.z.rem_assign(rhs.z);
1394 self.w.rem_assign(rhs.w);
1395 }
1396 }
1397
1398 impl RemAssign<&UVec4> for UVec4 {
1399 #[inline]
rem_assign(&mut self, rhs: &UVec4)1400 fn rem_assign(&mut self, rhs: &UVec4) {
1401 self.rem_assign(*rhs)
1402 }
1403 }
1404
1405 impl Rem<u32> for UVec4 {
1406 type Output = Self;
1407 #[inline]
rem(self, rhs: u32) -> Self1408 fn rem(self, rhs: u32) -> Self {
1409 Self {
1410 x: self.x.rem(rhs),
1411 y: self.y.rem(rhs),
1412 z: self.z.rem(rhs),
1413 w: self.w.rem(rhs),
1414 }
1415 }
1416 }
1417
1418 impl Rem<&u32> for UVec4 {
1419 type Output = UVec4;
1420 #[inline]
rem(self, rhs: &u32) -> UVec41421 fn rem(self, rhs: &u32) -> UVec4 {
1422 self.rem(*rhs)
1423 }
1424 }
1425
1426 impl Rem<&u32> for &UVec4 {
1427 type Output = UVec4;
1428 #[inline]
rem(self, rhs: &u32) -> UVec41429 fn rem(self, rhs: &u32) -> UVec4 {
1430 (*self).rem(*rhs)
1431 }
1432 }
1433
1434 impl Rem<u32> for &UVec4 {
1435 type Output = UVec4;
1436 #[inline]
rem(self, rhs: u32) -> UVec41437 fn rem(self, rhs: u32) -> UVec4 {
1438 (*self).rem(rhs)
1439 }
1440 }
1441
1442 impl RemAssign<u32> for UVec4 {
1443 #[inline]
rem_assign(&mut self, rhs: u32)1444 fn rem_assign(&mut self, rhs: u32) {
1445 self.x.rem_assign(rhs);
1446 self.y.rem_assign(rhs);
1447 self.z.rem_assign(rhs);
1448 self.w.rem_assign(rhs);
1449 }
1450 }
1451
1452 impl RemAssign<&u32> for UVec4 {
1453 #[inline]
rem_assign(&mut self, rhs: &u32)1454 fn rem_assign(&mut self, rhs: &u32) {
1455 self.rem_assign(*rhs)
1456 }
1457 }
1458
1459 impl Rem<UVec4> for u32 {
1460 type Output = UVec4;
1461 #[inline]
rem(self, rhs: UVec4) -> UVec41462 fn rem(self, rhs: UVec4) -> UVec4 {
1463 UVec4 {
1464 x: self.rem(rhs.x),
1465 y: self.rem(rhs.y),
1466 z: self.rem(rhs.z),
1467 w: self.rem(rhs.w),
1468 }
1469 }
1470 }
1471
1472 impl Rem<&UVec4> for u32 {
1473 type Output = UVec4;
1474 #[inline]
rem(self, rhs: &UVec4) -> UVec41475 fn rem(self, rhs: &UVec4) -> UVec4 {
1476 self.rem(*rhs)
1477 }
1478 }
1479
1480 impl Rem<&UVec4> for &u32 {
1481 type Output = UVec4;
1482 #[inline]
rem(self, rhs: &UVec4) -> UVec41483 fn rem(self, rhs: &UVec4) -> UVec4 {
1484 (*self).rem(*rhs)
1485 }
1486 }
1487
1488 impl Rem<UVec4> for &u32 {
1489 type Output = UVec4;
1490 #[inline]
rem(self, rhs: UVec4) -> UVec41491 fn rem(self, rhs: UVec4) -> UVec4 {
1492 (*self).rem(rhs)
1493 }
1494 }
1495
1496 #[cfg(not(target_arch = "spirv"))]
1497 impl AsRef<[u32; 4]> for UVec4 {
1498 #[inline]
as_ref(&self) -> &[u32; 4]1499 fn as_ref(&self) -> &[u32; 4] {
1500 unsafe { &*(self as *const UVec4 as *const [u32; 4]) }
1501 }
1502 }
1503
1504 #[cfg(not(target_arch = "spirv"))]
1505 impl AsMut<[u32; 4]> for UVec4 {
1506 #[inline]
as_mut(&mut self) -> &mut [u32; 4]1507 fn as_mut(&mut self) -> &mut [u32; 4] {
1508 unsafe { &mut *(self as *mut UVec4 as *mut [u32; 4]) }
1509 }
1510 }
1511
1512 impl Sum for UVec4 {
1513 #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = Self>,1514 fn sum<I>(iter: I) -> Self
1515 where
1516 I: Iterator<Item = Self>,
1517 {
1518 iter.fold(Self::ZERO, Self::add)
1519 }
1520 }
1521
1522 impl<'a> Sum<&'a Self> for UVec4 {
1523 #[inline]
sum<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,1524 fn sum<I>(iter: I) -> Self
1525 where
1526 I: Iterator<Item = &'a Self>,
1527 {
1528 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
1529 }
1530 }
1531
1532 impl Product for UVec4 {
1533 #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = Self>,1534 fn product<I>(iter: I) -> Self
1535 where
1536 I: Iterator<Item = Self>,
1537 {
1538 iter.fold(Self::ONE, Self::mul)
1539 }
1540 }
1541
1542 impl<'a> Product<&'a Self> for UVec4 {
1543 #[inline]
product<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>,1544 fn product<I>(iter: I) -> Self
1545 where
1546 I: Iterator<Item = &'a Self>,
1547 {
1548 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
1549 }
1550 }
1551
1552 impl Not for UVec4 {
1553 type Output = Self;
1554 #[inline]
not(self) -> Self::Output1555 fn not(self) -> Self::Output {
1556 Self {
1557 x: self.x.not(),
1558 y: self.y.not(),
1559 z: self.z.not(),
1560 w: self.w.not(),
1561 }
1562 }
1563 }
1564
1565 impl BitAnd for UVec4 {
1566 type Output = Self;
1567 #[inline]
bitand(self, rhs: Self) -> Self::Output1568 fn bitand(self, rhs: Self) -> Self::Output {
1569 Self {
1570 x: self.x.bitand(rhs.x),
1571 y: self.y.bitand(rhs.y),
1572 z: self.z.bitand(rhs.z),
1573 w: self.w.bitand(rhs.w),
1574 }
1575 }
1576 }
1577
1578 impl BitOr for UVec4 {
1579 type Output = Self;
1580 #[inline]
bitor(self, rhs: Self) -> Self::Output1581 fn bitor(self, rhs: Self) -> Self::Output {
1582 Self {
1583 x: self.x.bitor(rhs.x),
1584 y: self.y.bitor(rhs.y),
1585 z: self.z.bitor(rhs.z),
1586 w: self.w.bitor(rhs.w),
1587 }
1588 }
1589 }
1590
1591 impl BitXor for UVec4 {
1592 type Output = Self;
1593 #[inline]
bitxor(self, rhs: Self) -> Self::Output1594 fn bitxor(self, rhs: Self) -> Self::Output {
1595 Self {
1596 x: self.x.bitxor(rhs.x),
1597 y: self.y.bitxor(rhs.y),
1598 z: self.z.bitxor(rhs.z),
1599 w: self.w.bitxor(rhs.w),
1600 }
1601 }
1602 }
1603
1604 impl BitAnd<u32> for UVec4 {
1605 type Output = Self;
1606 #[inline]
bitand(self, rhs: u32) -> Self::Output1607 fn bitand(self, rhs: u32) -> Self::Output {
1608 Self {
1609 x: self.x.bitand(rhs),
1610 y: self.y.bitand(rhs),
1611 z: self.z.bitand(rhs),
1612 w: self.w.bitand(rhs),
1613 }
1614 }
1615 }
1616
1617 impl BitOr<u32> for UVec4 {
1618 type Output = Self;
1619 #[inline]
bitor(self, rhs: u32) -> Self::Output1620 fn bitor(self, rhs: u32) -> Self::Output {
1621 Self {
1622 x: self.x.bitor(rhs),
1623 y: self.y.bitor(rhs),
1624 z: self.z.bitor(rhs),
1625 w: self.w.bitor(rhs),
1626 }
1627 }
1628 }
1629
1630 impl BitXor<u32> for UVec4 {
1631 type Output = Self;
1632 #[inline]
bitxor(self, rhs: u32) -> Self::Output1633 fn bitxor(self, rhs: u32) -> Self::Output {
1634 Self {
1635 x: self.x.bitxor(rhs),
1636 y: self.y.bitxor(rhs),
1637 z: self.z.bitxor(rhs),
1638 w: self.w.bitxor(rhs),
1639 }
1640 }
1641 }
1642
1643 impl Shl<i8> for UVec4 {
1644 type Output = Self;
1645 #[inline]
shl(self, rhs: i8) -> Self::Output1646 fn shl(self, rhs: i8) -> Self::Output {
1647 Self {
1648 x: self.x.shl(rhs),
1649 y: self.y.shl(rhs),
1650 z: self.z.shl(rhs),
1651 w: self.w.shl(rhs),
1652 }
1653 }
1654 }
1655
1656 impl Shr<i8> for UVec4 {
1657 type Output = Self;
1658 #[inline]
shr(self, rhs: i8) -> Self::Output1659 fn shr(self, rhs: i8) -> Self::Output {
1660 Self {
1661 x: self.x.shr(rhs),
1662 y: self.y.shr(rhs),
1663 z: self.z.shr(rhs),
1664 w: self.w.shr(rhs),
1665 }
1666 }
1667 }
1668
1669 impl Shl<i16> for UVec4 {
1670 type Output = Self;
1671 #[inline]
shl(self, rhs: i16) -> Self::Output1672 fn shl(self, rhs: i16) -> Self::Output {
1673 Self {
1674 x: self.x.shl(rhs),
1675 y: self.y.shl(rhs),
1676 z: self.z.shl(rhs),
1677 w: self.w.shl(rhs),
1678 }
1679 }
1680 }
1681
1682 impl Shr<i16> for UVec4 {
1683 type Output = Self;
1684 #[inline]
shr(self, rhs: i16) -> Self::Output1685 fn shr(self, rhs: i16) -> Self::Output {
1686 Self {
1687 x: self.x.shr(rhs),
1688 y: self.y.shr(rhs),
1689 z: self.z.shr(rhs),
1690 w: self.w.shr(rhs),
1691 }
1692 }
1693 }
1694
1695 impl Shl<i32> for UVec4 {
1696 type Output = Self;
1697 #[inline]
shl(self, rhs: i32) -> Self::Output1698 fn shl(self, rhs: i32) -> Self::Output {
1699 Self {
1700 x: self.x.shl(rhs),
1701 y: self.y.shl(rhs),
1702 z: self.z.shl(rhs),
1703 w: self.w.shl(rhs),
1704 }
1705 }
1706 }
1707
1708 impl Shr<i32> for UVec4 {
1709 type Output = Self;
1710 #[inline]
shr(self, rhs: i32) -> Self::Output1711 fn shr(self, rhs: i32) -> Self::Output {
1712 Self {
1713 x: self.x.shr(rhs),
1714 y: self.y.shr(rhs),
1715 z: self.z.shr(rhs),
1716 w: self.w.shr(rhs),
1717 }
1718 }
1719 }
1720
1721 impl Shl<i64> for UVec4 {
1722 type Output = Self;
1723 #[inline]
shl(self, rhs: i64) -> Self::Output1724 fn shl(self, rhs: i64) -> Self::Output {
1725 Self {
1726 x: self.x.shl(rhs),
1727 y: self.y.shl(rhs),
1728 z: self.z.shl(rhs),
1729 w: self.w.shl(rhs),
1730 }
1731 }
1732 }
1733
1734 impl Shr<i64> for UVec4 {
1735 type Output = Self;
1736 #[inline]
shr(self, rhs: i64) -> Self::Output1737 fn shr(self, rhs: i64) -> Self::Output {
1738 Self {
1739 x: self.x.shr(rhs),
1740 y: self.y.shr(rhs),
1741 z: self.z.shr(rhs),
1742 w: self.w.shr(rhs),
1743 }
1744 }
1745 }
1746
1747 impl Shl<u8> for UVec4 {
1748 type Output = Self;
1749 #[inline]
shl(self, rhs: u8) -> Self::Output1750 fn shl(self, rhs: u8) -> Self::Output {
1751 Self {
1752 x: self.x.shl(rhs),
1753 y: self.y.shl(rhs),
1754 z: self.z.shl(rhs),
1755 w: self.w.shl(rhs),
1756 }
1757 }
1758 }
1759
1760 impl Shr<u8> for UVec4 {
1761 type Output = Self;
1762 #[inline]
shr(self, rhs: u8) -> Self::Output1763 fn shr(self, rhs: u8) -> Self::Output {
1764 Self {
1765 x: self.x.shr(rhs),
1766 y: self.y.shr(rhs),
1767 z: self.z.shr(rhs),
1768 w: self.w.shr(rhs),
1769 }
1770 }
1771 }
1772
1773 impl Shl<u16> for UVec4 {
1774 type Output = Self;
1775 #[inline]
shl(self, rhs: u16) -> Self::Output1776 fn shl(self, rhs: u16) -> Self::Output {
1777 Self {
1778 x: self.x.shl(rhs),
1779 y: self.y.shl(rhs),
1780 z: self.z.shl(rhs),
1781 w: self.w.shl(rhs),
1782 }
1783 }
1784 }
1785
1786 impl Shr<u16> for UVec4 {
1787 type Output = Self;
1788 #[inline]
shr(self, rhs: u16) -> Self::Output1789 fn shr(self, rhs: u16) -> Self::Output {
1790 Self {
1791 x: self.x.shr(rhs),
1792 y: self.y.shr(rhs),
1793 z: self.z.shr(rhs),
1794 w: self.w.shr(rhs),
1795 }
1796 }
1797 }
1798
1799 impl Shl<u32> for UVec4 {
1800 type Output = Self;
1801 #[inline]
shl(self, rhs: u32) -> Self::Output1802 fn shl(self, rhs: u32) -> Self::Output {
1803 Self {
1804 x: self.x.shl(rhs),
1805 y: self.y.shl(rhs),
1806 z: self.z.shl(rhs),
1807 w: self.w.shl(rhs),
1808 }
1809 }
1810 }
1811
1812 impl Shr<u32> for UVec4 {
1813 type Output = Self;
1814 #[inline]
shr(self, rhs: u32) -> Self::Output1815 fn shr(self, rhs: u32) -> Self::Output {
1816 Self {
1817 x: self.x.shr(rhs),
1818 y: self.y.shr(rhs),
1819 z: self.z.shr(rhs),
1820 w: self.w.shr(rhs),
1821 }
1822 }
1823 }
1824
1825 impl Shl<u64> for UVec4 {
1826 type Output = Self;
1827 #[inline]
shl(self, rhs: u64) -> Self::Output1828 fn shl(self, rhs: u64) -> Self::Output {
1829 Self {
1830 x: self.x.shl(rhs),
1831 y: self.y.shl(rhs),
1832 z: self.z.shl(rhs),
1833 w: self.w.shl(rhs),
1834 }
1835 }
1836 }
1837
1838 impl Shr<u64> for UVec4 {
1839 type Output = Self;
1840 #[inline]
shr(self, rhs: u64) -> Self::Output1841 fn shr(self, rhs: u64) -> Self::Output {
1842 Self {
1843 x: self.x.shr(rhs),
1844 y: self.y.shr(rhs),
1845 z: self.z.shr(rhs),
1846 w: self.w.shr(rhs),
1847 }
1848 }
1849 }
1850
1851 impl Shl<crate::IVec4> for UVec4 {
1852 type Output = Self;
1853 #[inline]
shl(self, rhs: crate::IVec4) -> Self::Output1854 fn shl(self, rhs: crate::IVec4) -> Self::Output {
1855 Self {
1856 x: self.x.shl(rhs.x),
1857 y: self.y.shl(rhs.y),
1858 z: self.z.shl(rhs.z),
1859 w: self.w.shl(rhs.w),
1860 }
1861 }
1862 }
1863
1864 impl Shr<crate::IVec4> for UVec4 {
1865 type Output = Self;
1866 #[inline]
shr(self, rhs: crate::IVec4) -> Self::Output1867 fn shr(self, rhs: crate::IVec4) -> Self::Output {
1868 Self {
1869 x: self.x.shr(rhs.x),
1870 y: self.y.shr(rhs.y),
1871 z: self.z.shr(rhs.z),
1872 w: self.w.shr(rhs.w),
1873 }
1874 }
1875 }
1876
1877 impl Shl<crate::UVec4> for UVec4 {
1878 type Output = Self;
1879 #[inline]
shl(self, rhs: crate::UVec4) -> Self::Output1880 fn shl(self, rhs: crate::UVec4) -> Self::Output {
1881 Self {
1882 x: self.x.shl(rhs.x),
1883 y: self.y.shl(rhs.y),
1884 z: self.z.shl(rhs.z),
1885 w: self.w.shl(rhs.w),
1886 }
1887 }
1888 }
1889
1890 impl Shr<crate::UVec4> for UVec4 {
1891 type Output = Self;
1892 #[inline]
shr(self, rhs: crate::UVec4) -> Self::Output1893 fn shr(self, rhs: crate::UVec4) -> Self::Output {
1894 Self {
1895 x: self.x.shr(rhs.x),
1896 y: self.y.shr(rhs.y),
1897 z: self.z.shr(rhs.z),
1898 w: self.w.shr(rhs.w),
1899 }
1900 }
1901 }
1902
1903 impl Index<usize> for UVec4 {
1904 type Output = u32;
1905 #[inline]
index(&self, index: usize) -> &Self::Output1906 fn index(&self, index: usize) -> &Self::Output {
1907 match index {
1908 0 => &self.x,
1909 1 => &self.y,
1910 2 => &self.z,
1911 3 => &self.w,
1912 _ => panic!("index out of bounds"),
1913 }
1914 }
1915 }
1916
1917 impl IndexMut<usize> for UVec4 {
1918 #[inline]
index_mut(&mut self, index: usize) -> &mut Self::Output1919 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1920 match index {
1921 0 => &mut self.x,
1922 1 => &mut self.y,
1923 2 => &mut self.z,
1924 3 => &mut self.w,
1925 _ => panic!("index out of bounds"),
1926 }
1927 }
1928 }
1929
1930 impl fmt::Display for UVec4 {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result1931 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1932 write!(f, "[{}, {}, {}, {}]", self.x, self.y, self.z, self.w)
1933 }
1934 }
1935
1936 impl fmt::Debug for UVec4 {
fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result1937 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1938 fmt.debug_tuple(stringify!(UVec4))
1939 .field(&self.x)
1940 .field(&self.y)
1941 .field(&self.z)
1942 .field(&self.w)
1943 .finish()
1944 }
1945 }
1946
1947 impl From<[u32; 4]> for UVec4 {
1948 #[inline]
from(a: [u32; 4]) -> Self1949 fn from(a: [u32; 4]) -> Self {
1950 Self::new(a[0], a[1], a[2], a[3])
1951 }
1952 }
1953
1954 impl From<UVec4> for [u32; 4] {
1955 #[inline]
from(v: UVec4) -> Self1956 fn from(v: UVec4) -> Self {
1957 [v.x, v.y, v.z, v.w]
1958 }
1959 }
1960
1961 impl From<(u32, u32, u32, u32)> for UVec4 {
1962 #[inline]
from(t: (u32, u32, u32, u32)) -> Self1963 fn from(t: (u32, u32, u32, u32)) -> Self {
1964 Self::new(t.0, t.1, t.2, t.3)
1965 }
1966 }
1967
1968 impl From<UVec4> for (u32, u32, u32, u32) {
1969 #[inline]
from(v: UVec4) -> Self1970 fn from(v: UVec4) -> Self {
1971 (v.x, v.y, v.z, v.w)
1972 }
1973 }
1974
1975 impl From<(UVec3, u32)> for UVec4 {
1976 #[inline]
from((v, w): (UVec3, u32)) -> Self1977 fn from((v, w): (UVec3, u32)) -> Self {
1978 Self::new(v.x, v.y, v.z, w)
1979 }
1980 }
1981
1982 impl From<(u32, UVec3)> for UVec4 {
1983 #[inline]
from((x, v): (u32, UVec3)) -> Self1984 fn from((x, v): (u32, UVec3)) -> Self {
1985 Self::new(x, v.x, v.y, v.z)
1986 }
1987 }
1988
1989 impl From<(UVec2, u32, u32)> for UVec4 {
1990 #[inline]
from((v, z, w): (UVec2, u32, u32)) -> Self1991 fn from((v, z, w): (UVec2, u32, u32)) -> Self {
1992 Self::new(v.x, v.y, z, w)
1993 }
1994 }
1995
1996 impl From<(UVec2, UVec2)> for UVec4 {
1997 #[inline]
from((v, u): (UVec2, UVec2)) -> Self1998 fn from((v, u): (UVec2, UVec2)) -> Self {
1999 Self::new(v.x, v.y, u.x, u.y)
2000 }
2001 }
2002
2003 impl From<U8Vec4> for UVec4 {
2004 #[inline]
from(v: U8Vec4) -> Self2005 fn from(v: U8Vec4) -> Self {
2006 Self::new(
2007 u32::from(v.x),
2008 u32::from(v.y),
2009 u32::from(v.z),
2010 u32::from(v.w),
2011 )
2012 }
2013 }
2014
2015 impl From<U16Vec4> for UVec4 {
2016 #[inline]
from(v: U16Vec4) -> Self2017 fn from(v: U16Vec4) -> Self {
2018 Self::new(
2019 u32::from(v.x),
2020 u32::from(v.y),
2021 u32::from(v.z),
2022 u32::from(v.w),
2023 )
2024 }
2025 }
2026
2027 impl TryFrom<I8Vec4> for UVec4 {
2028 type Error = core::num::TryFromIntError;
2029
2030 #[inline]
try_from(v: I8Vec4) -> Result<Self, Self::Error>2031 fn try_from(v: I8Vec4) -> Result<Self, Self::Error> {
2032 Ok(Self::new(
2033 u32::try_from(v.x)?,
2034 u32::try_from(v.y)?,
2035 u32::try_from(v.z)?,
2036 u32::try_from(v.w)?,
2037 ))
2038 }
2039 }
2040
2041 impl TryFrom<I16Vec4> for UVec4 {
2042 type Error = core::num::TryFromIntError;
2043
2044 #[inline]
try_from(v: I16Vec4) -> Result<Self, Self::Error>2045 fn try_from(v: I16Vec4) -> Result<Self, Self::Error> {
2046 Ok(Self::new(
2047 u32::try_from(v.x)?,
2048 u32::try_from(v.y)?,
2049 u32::try_from(v.z)?,
2050 u32::try_from(v.w)?,
2051 ))
2052 }
2053 }
2054
2055 impl TryFrom<IVec4> for UVec4 {
2056 type Error = core::num::TryFromIntError;
2057
2058 #[inline]
try_from(v: IVec4) -> Result<Self, Self::Error>2059 fn try_from(v: IVec4) -> Result<Self, Self::Error> {
2060 Ok(Self::new(
2061 u32::try_from(v.x)?,
2062 u32::try_from(v.y)?,
2063 u32::try_from(v.z)?,
2064 u32::try_from(v.w)?,
2065 ))
2066 }
2067 }
2068
2069 impl TryFrom<I64Vec4> for UVec4 {
2070 type Error = core::num::TryFromIntError;
2071
2072 #[inline]
try_from(v: I64Vec4) -> Result<Self, Self::Error>2073 fn try_from(v: I64Vec4) -> Result<Self, Self::Error> {
2074 Ok(Self::new(
2075 u32::try_from(v.x)?,
2076 u32::try_from(v.y)?,
2077 u32::try_from(v.z)?,
2078 u32::try_from(v.w)?,
2079 ))
2080 }
2081 }
2082
2083 impl TryFrom<U64Vec4> for UVec4 {
2084 type Error = core::num::TryFromIntError;
2085
2086 #[inline]
try_from(v: U64Vec4) -> Result<Self, Self::Error>2087 fn try_from(v: U64Vec4) -> Result<Self, Self::Error> {
2088 Ok(Self::new(
2089 u32::try_from(v.x)?,
2090 u32::try_from(v.y)?,
2091 u32::try_from(v.z)?,
2092 u32::try_from(v.w)?,
2093 ))
2094 }
2095 }
2096
2097 impl From<BVec4> for UVec4 {
2098 #[inline]
from(v: BVec4) -> Self2099 fn from(v: BVec4) -> Self {
2100 Self::new(
2101 u32::from(v.x),
2102 u32::from(v.y),
2103 u32::from(v.z),
2104 u32::from(v.w),
2105 )
2106 }
2107 }
2108
2109 #[cfg(not(feature = "scalar-math"))]
2110 impl From<BVec4A> for UVec4 {
2111 #[inline]
from(v: BVec4A) -> Self2112 fn from(v: BVec4A) -> Self {
2113 let bool_array: [bool; 4] = v.into();
2114 Self::new(
2115 u32::from(bool_array[0]),
2116 u32::from(bool_array[1]),
2117 u32::from(bool_array[2]),
2118 u32::from(bool_array[3]),
2119 )
2120 }
2121 }
2122