Debian Codegraph @

debian/missing-sources/glam-0.28.0/src/u64/u64vec2.rs

raw symbols SCIP
1 // Generated from vec.rs.tera template. Edit the template, not the generated file.
2
3 use crate::{BVec2, I16Vec2, I64Vec2, IVec2, U16Vec2, U64Vec3, UVec2};
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 #[must_use]
13 pub const fn u64vec2(x: u64, y: u64) -> U64Vec2 {
14 U64Vec2::new(x, y)
15 }
16
17 /// A 2-dimensional vector.
18 #[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
19 #[derive(Clone, Copy, PartialEq, Eq)]
20 #[cfg_attr(feature = "cuda", repr(align(16)))]
21 #[cfg_attr(not(target_arch = "spirv"), repr(C))]
22 #[cfg_attr(target_arch = "spirv", repr(simd))]
23 pub struct U64Vec2 {
24 pub x: u64,
25 pub y: u64,
26 }
27
28 impl U64Vec2 {
29 /// All zeroes.
30 pub const ZERO: Self = Self::splat(0);
31
32 /// All ones.
33 pub const ONE: Self = Self::splat(1);
34
35 /// All `u64::MIN`.
36 pub const MIN: Self = Self::splat(u64::MIN);
37
38 /// All `u64::MAX`.
39 pub const MAX: Self = Self::splat(u64::MAX);
40
41 /// A unit vector pointing along the positive X axis.
42 pub const X: Self = Self::new(1, 0);
43
44 /// A unit vector pointing along the positive Y axis.
45 pub const Y: Self = Self::new(0, 1);
46
47 /// The unit axes.
48 pub const AXES: [Self; 2] = [Self::X, Self::Y];
49
50 /// Creates a new vector.
51 #[inline(always)]
52 #[must_use]
53 pub const fn new(x: u64, y: u64) -> Self {
54 Self { x, y }
55 }
56
57 /// Creates a vector with all elements set to `v`.
58 #[inline]
59 #[must_use]
60 pub const fn splat(v: u64) -> Self {
61 Self { x: v, y: v }
62 }
63
64 /// Creates a vector from the elements in `if_true` and `if_false`, selecting which to use
65 /// for each element of `self`.
66 ///
67 /// A true element in the mask uses the corresponding element from `if_true`, and false
68 /// uses the element from `if_false`.
69 #[inline]
70 #[must_use]
71 pub fn select(mask: BVec2, if_true: Self, if_false: Self) -> Self {
72 Self {
73 x: if mask.test(0) { if_true.x } else { if_false.x },
74 y: if mask.test(1) { if_true.y } else { if_false.y },
75 }
76 }
77
78 /// Creates a new vector from an array.
79 #[inline]
80 #[must_use]
81 pub const fn from_array(a: [u64; 2]) -> Self {
82 Self::new(a[0], a[1])
83 }
84
85 /// `[x, y]`
86 #[inline]
87 #[must_use]
88 pub const fn to_array(&self) -> [u64; 2] {
89 [self.x, self.y]
90 }
91
92 /// Creates a vector from the first 2 values in `slice`.
93 ///
94 /// # Panics
95 ///
96 /// Panics if `slice` is less than 2 elements long.
97 #[inline]
98 #[must_use]
99 pub const fn from_slice(slice: &[u64]) -> Self {
100 Self::new(slice[0], slice[1])
101 }
102
103 /// Writes the elements of `self` to the first 2 elements in `slice`.
104 ///
105 /// # Panics
106 ///
107 /// Panics if `slice` is less than 2 elements long.
108 #[inline]
109 pub fn write_to_slice(self, slice: &mut [u64]) {
110 slice[0] = self.x;
111 slice[1] = self.y;
112 }
113
114 /// Creates a 3D vector from `self` and the given `z` value.
115 #[inline]
116 #[must_use]
117 pub const fn extend(self, z: u64) -> U64Vec3 {
118 U64Vec3::new(self.x, self.y, z)
119 }
120
121 /// Creates a 2D vector from `self` with the given value of `x`.
122 #[inline]
123 #[must_use]
124 pub fn with_x(mut self, x: u64) -> Self {
125 self.x = x;
126 self
127 }
128
129 /// Creates a 2D vector from `self` with the given value of `y`.
130 #[inline]
131 #[must_use]
132 pub fn with_y(mut self, y: u64) -> Self {
133 self.y = y;
134 self
135 }
136
137 /// Computes the dot product of `self` and `rhs`.
138 #[inline]
139 #[must_use]
140 pub fn dot(self, rhs: Self) -> u64 {
141 (self.x * rhs.x) + (self.y * rhs.y)
142 }
143
144 /// Returns a vector where every component is the dot product of `self` and `rhs`.
145 #[inline]
146 #[must_use]
147 pub fn dot_into_vec(self, rhs: Self) -> Self {
148 Self::splat(self.dot(rhs))
149 }
150
151 /// Returns a vector containing the minimum values for each element of `self` and `rhs`.
152 ///
153 /// In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`.
154 #[inline]
155 #[must_use]
156 pub fn min(self, rhs: Self) -> Self {
157 Self {
158 x: self.x.min(rhs.x),
159 y: self.y.min(rhs.y),
160 }
161 }
162
163 /// Returns a vector containing the maximum values for each element of `self` and `rhs`.
164 ///
165 /// In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`.
166 #[inline]
167 #[must_use]
168 pub fn max(self, rhs: Self) -> Self {
169 Self {
170 x: self.x.max(rhs.x),
171 y: self.y.max(rhs.y),
172 }
173 }
174
175 /// Component-wise clamping of values, similar to [`u64::clamp`].
176 ///
177 /// Each element in `min` must be less-or-equal to the corresponding element in `max`.
178 ///
179 /// # Panics
180 ///
181 /// Will panic if `min` is greater than `max` when `glam_assert` is enabled.
182 #[inline]
183 #[must_use]
184 pub fn clamp(self, min: Self, max: Self) -> Self {
185 glam_assert!(min.cmple(max).all(), "clamp: expected min <= max");
186 self.max(min).min(max)
187 }
188
189 /// Returns the horizontal minimum of `self`.
190 ///
191 /// In other words this computes `min(x, y, ..)`.
192 #[inline]
193 #[must_use]
194 pub fn min_element(self) -> u64 {
195 self.x.min(self.y)
196 }
197
198 /// Returns the horizontal maximum of `self`.
199 ///
200 /// In other words this computes `max(x, y, ..)`.
201 #[inline]
202 #[must_use]
203 pub fn max_element(self) -> u64 {
204 self.x.max(self.y)
205 }
206
207 /// Returns the sum of all elements of `self`.
208 ///
209 /// In other words, this computes `self.x + self.y + ..`.
210 #[inline]
211 #[must_use]
212 pub fn element_sum(self) -> u64 {
213 self.x + self.y
214 }
215
216 /// Returns the product of all elements of `self`.
217 ///
218 /// In other words, this computes `self.x * self.y * ..`.
219 #[inline]
220 #[must_use]
221 pub fn element_product(self) -> u64 {
222 self.x * self.y
223 }
224
225 /// Returns a vector mask containing the result of a `==` comparison for each element of
226 /// `self` and `rhs`.
227 ///
228 /// In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all
229 /// elements.
230 #[inline]
231 #[must_use]
232 pub fn cmpeq(self, rhs: Self) -> BVec2 {
233 BVec2::new(self.x.eq(&rhs.x), self.y.eq(&rhs.y))
234 }
235
236 /// Returns a vector mask containing the result of a `!=` comparison for each element of
237 /// `self` and `rhs`.
238 ///
239 /// In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all
240 /// elements.
241 #[inline]
242 #[must_use]
243 pub fn cmpne(self, rhs: Self) -> BVec2 {
244 BVec2::new(self.x.ne(&rhs.x), self.y.ne(&rhs.y))
245 }
246
247 /// Returns a vector mask containing the result of a `>=` comparison for each element of
248 /// `self` and `rhs`.
249 ///
250 /// In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all
251 /// elements.
252 #[inline]
253 #[must_use]
254 pub fn cmpge(self, rhs: Self) -> BVec2 {
255 BVec2::new(self.x.ge(&rhs.x), self.y.ge(&rhs.y))
256 }
257
258 /// Returns a vector mask containing the result of a `>` comparison for each element of
259 /// `self` and `rhs`.
260 ///
261 /// In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all
262 /// elements.
263 #[inline]
264 #[must_use]
265 pub fn cmpgt(self, rhs: Self) -> BVec2 {
266 BVec2::new(self.x.gt(&rhs.x), self.y.gt(&rhs.y))
267 }
268
269 /// Returns a vector mask containing the result of a `<=` comparison for each element of
270 /// `self` and `rhs`.
271 ///
272 /// In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all
273 /// elements.
274 #[inline]
275 #[must_use]
276 pub fn cmple(self, rhs: Self) -> BVec2 {
277 BVec2::new(self.x.le(&rhs.x), self.y.le(&rhs.y))
278 }
279
280 /// Returns a vector mask containing the result of a `<` comparison for each element of
281 /// `self` and `rhs`.
282 ///
283 /// In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all
284 /// elements.
285 #[inline]
286 #[must_use]
287 pub fn cmplt(self, rhs: Self) -> BVec2 {
288 BVec2::new(self.x.lt(&rhs.x), self.y.lt(&rhs.y))
289 }
290
291 /// Computes the squared length of `self`.
292 #[doc(alias = "magnitude2")]
293 #[inline]
294 #[must_use]
295 pub fn length_squared(self) -> u64 {
296 self.dot(self)
297 }
298
299 /// Casts all elements of `self` to `f32`.
300 #[inline]
301 #[must_use]
302 pub fn as_vec2(&self) -> crate::Vec2 {
303 crate::Vec2::new(self.x as f32, self.y as f32)
304 }
305
306 /// Casts all elements of `self` to `f64`.
307 #[inline]
308 #[must_use]
309 pub fn as_dvec2(&self) -> crate::DVec2 {
310 crate::DVec2::new(self.x as f64, self.y as f64)
311 }
312
313 /// Casts all elements of `self` to `i16`.
314 #[inline]
315 #[must_use]
316 pub fn as_i16vec2(&self) -> crate::I16Vec2 {
317 crate::I16Vec2::new(self.x as i16, self.y as i16)
318 }
319
320 /// Casts all elements of `self` to `u16`.
321 #[inline]
322 #[must_use]
323 pub fn as_u16vec2(&self) -> crate::U16Vec2 {
324 crate::U16Vec2::new(self.x as u16, self.y as u16)
325 }
326
327 /// Casts all elements of `self` to `i32`.
328 #[inline]
329 #[must_use]
330 pub fn as_ivec2(&self) -> crate::IVec2 {
331 crate::IVec2::new(self.x as i32, self.y as i32)
332 }
333
334 /// Casts all elements of `self` to `u32`.
335 #[inline]
336 #[must_use]
337 pub fn as_uvec2(&self) -> crate::UVec2 {
338 crate::UVec2::new(self.x as u32, self.y as u32)
339 }
340
341 /// Casts all elements of `self` to `i64`.
342 #[inline]
343 #[must_use]
344 pub fn as_i64vec2(&self) -> crate::I64Vec2 {
345 crate::I64Vec2::new(self.x as i64, self.y as i64)
346 }
347
348 /// Returns a vector containing the wrapping addition of `self` and `rhs`.
349 ///
350 /// In other words this computes `[self.x.wrapping_add(rhs.x), self.y.wrapping_add(rhs.y), ..]`.
351 #[inline]
352 #[must_use]
353 pub const fn wrapping_add(self, rhs: Self) -> Self {
354 Self {
355 x: self.x.wrapping_add(rhs.x),
356 y: self.y.wrapping_add(rhs.y),
357 }
358 }
359
360 /// Returns a vector containing the wrapping subtraction of `self` and `rhs`.
361 ///
362 /// In other words this computes `[self.x.wrapping_sub(rhs.x), self.y.wrapping_sub(rhs.y), ..]`.
363 #[inline]
364 #[must_use]
365 pub const fn wrapping_sub(self, rhs: Self) -> Self {
366 Self {
367 x: self.x.wrapping_sub(rhs.x),
368 y: self.y.wrapping_sub(rhs.y),
369 }
370 }
371
372 /// Returns a vector containing the wrapping multiplication of `self` and `rhs`.
373 ///
374 /// In other words this computes `[self.x.wrapping_mul(rhs.x), self.y.wrapping_mul(rhs.y), ..]`.
375 #[inline]
376 #[must_use]
377 pub const fn wrapping_mul(self, rhs: Self) -> Self {
378 Self {
379 x: self.x.wrapping_mul(rhs.x),
380 y: self.y.wrapping_mul(rhs.y),
381 }
382 }
383
384 /// Returns a vector containing the wrapping division of `self` and `rhs`.
385 ///
386 /// In other words this computes `[self.x.wrapping_div(rhs.x), self.y.wrapping_div(rhs.y), ..]`.
387 #[inline]
388 #[must_use]
389 pub const fn wrapping_div(self, rhs: Self) -> Self {
390 Self {
391 x: self.x.wrapping_div(rhs.x),
392 y: self.y.wrapping_div(rhs.y),
393 }
394 }
395
396 /// Returns a vector containing the saturating addition of `self` and `rhs`.
397 ///
398 /// In other words this computes `[self.x.saturating_add(rhs.x), self.y.saturating_add(rhs.y), ..]`.
399 #[inline]
400 #[must_use]
401 pub const fn saturating_add(self, rhs: Self) -> Self {
402 Self {
403 x: self.x.saturating_add(rhs.x),
404 y: self.y.saturating_add(rhs.y),
405 }
406 }
407
408 /// Returns a vector containing the saturating subtraction of `self` and `rhs`.
409 ///
410 /// In other words this computes `[self.x.saturating_sub(rhs.x), self.y.saturating_sub(rhs.y), ..]`.
411 #[inline]
412 #[must_use]
413 pub const fn saturating_sub(self, rhs: Self) -> Self {
414 Self {
415 x: self.x.saturating_sub(rhs.x),
416 y: self.y.saturating_sub(rhs.y),
417 }
418 }
419
420 /// Returns a vector containing the saturating multiplication of `self` and `rhs`.
421 ///
422 /// In other words this computes `[self.x.saturating_mul(rhs.x), self.y.saturating_mul(rhs.y), ..]`.
423 #[inline]
424 #[must_use]
425 pub const fn saturating_mul(self, rhs: Self) -> Self {
426 Self {
427 x: self.x.saturating_mul(rhs.x),
428 y: self.y.saturating_mul(rhs.y),
429 }
430 }
431
432 /// Returns a vector containing the saturating division of `self` and `rhs`.
433 ///
434 /// In other words this computes `[self.x.saturating_div(rhs.x), self.y.saturating_div(rhs.y), ..]`.
435 #[inline]
436 #[must_use]
437 pub const fn saturating_div(self, rhs: Self) -> Self {
438 Self {
439 x: self.x.saturating_div(rhs.x),
440 y: self.y.saturating_div(rhs.y),
441 }
442 }
443
444 /// Returns a vector containing the wrapping addition of `self` and signed vector `rhs`.
445 ///
446 /// In other words this computes `[self.x.wrapping_add_signed(rhs.x), self.y.wrapping_add_signed(rhs.y), ..]`.
447 #[inline]
448 #[must_use]
449 pub const fn wrapping_add_signed(self, rhs: I64Vec2) -> Self {
450 Self {
451 x: self.x.wrapping_add_signed(rhs.x),
452 y: self.y.wrapping_add_signed(rhs.y),
453 }
454 }
455
456 /// Returns a vector containing the saturating addition of `self` and signed vector `rhs`.
457 ///
458 /// In other words this computes `[self.x.saturating_add_signed(rhs.x), self.y.saturating_add_signed(rhs.y), ..]`.
459 #[inline]
460 #[must_use]
461 pub const fn saturating_add_signed(self, rhs: I64Vec2) -> Self {
462 Self {
463 x: self.x.saturating_add_signed(rhs.x),
464 y: self.y.saturating_add_signed(rhs.y),
465 }
466 }
467 }
468
469 impl Default for U64Vec2 {
470 #[inline(always)]
471 fn default() -> Self {
472 Self::ZERO
473 }
474 }
475
476 impl Div<U64Vec2> for U64Vec2 {
477 type Output = Self;
478 #[inline]
479 fn div(self, rhs: Self) -> Self {
480 Self {
481 x: self.x.div(rhs.x),
482 y: self.y.div(rhs.y),
483 }
484 }
485 }
486
487 impl DivAssign<U64Vec2> for U64Vec2 {
488 #[inline]
489 fn div_assign(&mut self, rhs: Self) {
490 self.x.div_assign(rhs.x);
491 self.y.div_assign(rhs.y);
492 }
493 }
494
495 impl Div<u64> for U64Vec2 {
496 type Output = Self;
497 #[inline]
498 fn div(self, rhs: u64) -> Self {
499 Self {
500 x: self.x.div(rhs),
501 y: self.y.div(rhs),
502 }
503 }
504 }
505
506 impl DivAssign<u64> for U64Vec2 {
507 #[inline]
508 fn div_assign(&mut self, rhs: u64) {
509 self.x.div_assign(rhs);
510 self.y.div_assign(rhs);
511 }
512 }
513
514 impl Div<U64Vec2> for u64 {
515 type Output = U64Vec2;
516 #[inline]
517 fn div(self, rhs: U64Vec2) -> U64Vec2 {
518 U64Vec2 {
519 x: self.div(rhs.x),
520 y: self.div(rhs.y),
521 }
522 }
523 }
524
525 impl Mul<U64Vec2> for U64Vec2 {
526 type Output = Self;
527 #[inline]
528 fn mul(self, rhs: Self) -> Self {
529 Self {
530 x: self.x.mul(rhs.x),
531 y: self.y.mul(rhs.y),
532 }
533 }
534 }
535
536 impl MulAssign<U64Vec2> for U64Vec2 {
537 #[inline]
538 fn mul_assign(&mut self, rhs: Self) {
539 self.x.mul_assign(rhs.x);
540 self.y.mul_assign(rhs.y);
541 }
542 }
543
544 impl Mul<u64> for U64Vec2 {
545 type Output = Self;
546 #[inline]
547 fn mul(self, rhs: u64) -> Self {
548 Self {
549 x: self.x.mul(rhs),
550 y: self.y.mul(rhs),
551 }
552 }
553 }
554
555 impl MulAssign<u64> for U64Vec2 {
556 #[inline]
557 fn mul_assign(&mut self, rhs: u64) {
558 self.x.mul_assign(rhs);
559 self.y.mul_assign(rhs);
560 }
561 }
562
563 impl Mul<U64Vec2> for u64 {
564 type Output = U64Vec2;
565 #[inline]
566 fn mul(self, rhs: U64Vec2) -> U64Vec2 {
567 U64Vec2 {
568 x: self.mul(rhs.x),
569 y: self.mul(rhs.y),
570 }
571 }
572 }
573
574 impl Add<U64Vec2> for U64Vec2 {
575 type Output = Self;
576 #[inline]
577 fn add(self, rhs: Self) -> Self {
578 Self {
579 x: self.x.add(rhs.x),
580 y: self.y.add(rhs.y),
581 }
582 }
583 }
584
585 impl AddAssign<U64Vec2> for U64Vec2 {
586 #[inline]
587 fn add_assign(&mut self, rhs: Self) {
588 self.x.add_assign(rhs.x);
589 self.y.add_assign(rhs.y);
590 }
591 }
592
593 impl Add<u64> for U64Vec2 {
594 type Output = Self;
595 #[inline]
596 fn add(self, rhs: u64) -> Self {
597 Self {
598 x: self.x.add(rhs),
599 y: self.y.add(rhs),
600 }
601 }
602 }
603
604 impl AddAssign<u64> for U64Vec2 {
605 #[inline]
606 fn add_assign(&mut self, rhs: u64) {
607 self.x.add_assign(rhs);
608 self.y.add_assign(rhs);
609 }
610 }
611
612 impl Add<U64Vec2> for u64 {
613 type Output = U64Vec2;
614 #[inline]
615 fn add(self, rhs: U64Vec2) -> U64Vec2 {
616 U64Vec2 {
617 x: self.add(rhs.x),
618 y: self.add(rhs.y),
619 }
620 }
621 }
622
623 impl Sub<U64Vec2> for U64Vec2 {
624 type Output = Self;
625 #[inline]
626 fn sub(self, rhs: Self) -> Self {
627 Self {
628 x: self.x.sub(rhs.x),
629 y: self.y.sub(rhs.y),
630 }
631 }
632 }
633
634 impl SubAssign<U64Vec2> for U64Vec2 {
635 #[inline]
636 fn sub_assign(&mut self, rhs: U64Vec2) {
637 self.x.sub_assign(rhs.x);
638 self.y.sub_assign(rhs.y);
639 }
640 }
641
642 impl Sub<u64> for U64Vec2 {
643 type Output = Self;
644 #[inline]
645 fn sub(self, rhs: u64) -> Self {
646 Self {
647 x: self.x.sub(rhs),
648 y: self.y.sub(rhs),
649 }
650 }
651 }
652
653 impl SubAssign<u64> for U64Vec2 {
654 #[inline]
655 fn sub_assign(&mut self, rhs: u64) {
656 self.x.sub_assign(rhs);
657 self.y.sub_assign(rhs);
658 }
659 }
660
661 impl Sub<U64Vec2> for u64 {
662 type Output = U64Vec2;
663 #[inline]
664 fn sub(self, rhs: U64Vec2) -> U64Vec2 {
665 U64Vec2 {
666 x: self.sub(rhs.x),
667 y: self.sub(rhs.y),
668 }
669 }
670 }
671
672 impl Rem<U64Vec2> for U64Vec2 {
673 type Output = Self;
674 #[inline]
675 fn rem(self, rhs: Self) -> Self {
676 Self {
677 x: self.x.rem(rhs.x),
678 y: self.y.rem(rhs.y),
679 }
680 }
681 }
682
683 impl RemAssign<U64Vec2> for U64Vec2 {
684 #[inline]
685 fn rem_assign(&mut self, rhs: Self) {
686 self.x.rem_assign(rhs.x);
687 self.y.rem_assign(rhs.y);
688 }
689 }
690
691 impl Rem<u64> for U64Vec2 {
692 type Output = Self;
693 #[inline]
694 fn rem(self, rhs: u64) -> Self {
695 Self {
696 x: self.x.rem(rhs),
697 y: self.y.rem(rhs),
698 }
699 }
700 }
701
702 impl RemAssign<u64> for U64Vec2 {
703 #[inline]
704 fn rem_assign(&mut self, rhs: u64) {
705 self.x.rem_assign(rhs);
706 self.y.rem_assign(rhs);
707 }
708 }
709
710 impl Rem<U64Vec2> for u64 {
711 type Output = U64Vec2;
712 #[inline]
713 fn rem(self, rhs: U64Vec2) -> U64Vec2 {
714 U64Vec2 {
715 x: self.rem(rhs.x),
716 y: self.rem(rhs.y),
717 }
718 }
719 }
720
721 #[cfg(not(target_arch = "spirv"))]
722 impl AsRef<[u64; 2]> for U64Vec2 {
723 #[inline]
724 fn as_ref(&self) -> &[u64; 2] {
725 unsafe { &*(self as *const U64Vec2 as *const [u64; 2]) }
726 }
727 }
728
729 #[cfg(not(target_arch = "spirv"))]
730 impl AsMut<[u64; 2]> for U64Vec2 {
731 #[inline]
732 fn as_mut(&mut self) -> &mut [u64; 2] {
733 unsafe { &mut *(self as *mut U64Vec2 as *mut [u64; 2]) }
734 }
735 }
736
737 impl Sum for U64Vec2 {
738 #[inline]
739 fn sum<I>(iter: I) -> Self
740 where
741 I: Iterator<Item = Self>,
742 {
743 iter.fold(Self::ZERO, Self::add)
744 }
745 }
746
747 impl<'a> Sum<&'a Self> for U64Vec2 {
748 #[inline]
749 fn sum<I>(iter: I) -> Self
750 where
751 I: Iterator<Item = &'a Self>,
752 {
753 iter.fold(Self::ZERO, |a, &b| Self::add(a, b))
754 }
755 }
756
757 impl Product for U64Vec2 {
758 #[inline]
759 fn product<I>(iter: I) -> Self
760 where
761 I: Iterator<Item = Self>,
762 {
763 iter.fold(Self::ONE, Self::mul)
764 }
765 }
766
767 impl<'a> Product<&'a Self> for U64Vec2 {
768 #[inline]
769 fn product<I>(iter: I) -> Self
770 where
771 I: Iterator<Item = &'a Self>,
772 {
773 iter.fold(Self::ONE, |a, &b| Self::mul(a, b))
774 }
775 }
776
777 impl Not for U64Vec2 {
778 type Output = Self;
779 #[inline]
780 fn not(self) -> Self::Output {
781 Self {
782 x: self.x.not(),
783 y: self.y.not(),
784 }
785 }
786 }
787
788 impl BitAnd for U64Vec2 {
789 type Output = Self;
790 #[inline]
791 fn bitand(self, rhs: Self) -> Self::Output {
792 Self {
793 x: self.x.bitand(rhs.x),
794 y: self.y.bitand(rhs.y),
795 }
796 }
797 }
798
799 impl BitOr for U64Vec2 {
800 type Output = Self;
801 #[inline]
802 fn bitor(self, rhs: Self) -> Self::Output {
803 Self {
804 x: self.x.bitor(rhs.x),
805 y: self.y.bitor(rhs.y),
806 }
807 }
808 }
809
810 impl BitXor for U64Vec2 {
811 type Output = Self;
812 #[inline]
813 fn bitxor(self, rhs: Self) -> Self::Output {
814 Self {
815 x: self.x.bitxor(rhs.x),
816 y: self.y.bitxor(rhs.y),
817 }
818 }
819 }
820
821 impl BitAnd<u64> for U64Vec2 {
822 type Output = Self;
823 #[inline]
824 fn bitand(self, rhs: u64) -> Self::Output {
825 Self {
826 x: self.x.bitand(rhs),
827 y: self.y.bitand(rhs),
828 }
829 }
830 }
831
832 impl BitOr<u64> for U64Vec2 {
833 type Output = Self;
834 #[inline]
835 fn bitor(self, rhs: u64) -> Self::Output {
836 Self {
837 x: self.x.bitor(rhs),
838 y: self.y.bitor(rhs),
839 }
840 }
841 }
842
843 impl BitXor<u64> for U64Vec2 {
844 type Output = Self;
845 #[inline]
846 fn bitxor(self, rhs: u64) -> Self::Output {
847 Self {
848 x: self.x.bitxor(rhs),
849 y: self.y.bitxor(rhs),
850 }
851 }
852 }
853
854 impl Shl<i8> for U64Vec2 {
855 type Output = Self;
856 #[inline]
857 fn shl(self, rhs: i8) -> Self::Output {
858 Self {
859 x: self.x.shl(rhs),
860 y: self.y.shl(rhs),
861 }
862 }
863 }
864
865 impl Shr<i8> for U64Vec2 {
866 type Output = Self;
867 #[inline]
868 fn shr(self, rhs: i8) -> Self::Output {
869 Self {
870 x: self.x.shr(rhs),
871 y: self.y.shr(rhs),
872 }
873 }
874 }
875
876 impl Shl<i16> for U64Vec2 {
877 type Output = Self;
878 #[inline]
879 fn shl(self, rhs: i16) -> Self::Output {
880 Self {
881 x: self.x.shl(rhs),
882 y: self.y.shl(rhs),
883 }
884 }
885 }
886
887 impl Shr<i16> for U64Vec2 {
888 type Output = Self;
889 #[inline]
890 fn shr(self, rhs: i16) -> Self::Output {
891 Self {
892 x: self.x.shr(rhs),
893 y: self.y.shr(rhs),
894 }
895 }
896 }
897
898 impl Shl<i32> for U64Vec2 {
899 type Output = Self;
900 #[inline]
901 fn shl(self, rhs: i32) -> Self::Output {
902 Self {
903 x: self.x.shl(rhs),
904 y: self.y.shl(rhs),
905 }
906 }
907 }
908
909 impl Shr<i32> for U64Vec2 {
910 type Output = Self;
911 #[inline]
912 fn shr(self, rhs: i32) -> Self::Output {
913 Self {
914 x: self.x.shr(rhs),
915 y: self.y.shr(rhs),
916 }
917 }
918 }
919
920 impl Shl<i64> for U64Vec2 {
921 type Output = Self;
922 #[inline]
923 fn shl(self, rhs: i64) -> Self::Output {
924 Self {
925 x: self.x.shl(rhs),
926 y: self.y.shl(rhs),
927 }
928 }
929 }
930
931 impl Shr<i64> for U64Vec2 {
932 type Output = Self;
933 #[inline]
934 fn shr(self, rhs: i64) -> Self::Output {
935 Self {
936 x: self.x.shr(rhs),
937 y: self.y.shr(rhs),
938 }
939 }
940 }
941
942 impl Shl<u8> for U64Vec2 {
943 type Output = Self;
944 #[inline]
945 fn shl(self, rhs: u8) -> Self::Output {
946 Self {
947 x: self.x.shl(rhs),
948 y: self.y.shl(rhs),
949 }
950 }
951 }
952
953 impl Shr<u8> for U64Vec2 {
954 type Output = Self;
955 #[inline]
956 fn shr(self, rhs: u8) -> Self::Output {
957 Self {
958 x: self.x.shr(rhs),
959 y: self.y.shr(rhs),
960 }
961 }
962 }
963
964 impl Shl<u16> for U64Vec2 {
965 type Output = Self;
966 #[inline]
967 fn shl(self, rhs: u16) -> Self::Output {
968 Self {
969 x: self.x.shl(rhs),
970 y: self.y.shl(rhs),
971 }
972 }
973 }
974
975 impl Shr<u16> for U64Vec2 {
976 type Output = Self;
977 #[inline]
978 fn shr(self, rhs: u16) -> Self::Output {
979 Self {
980 x: self.x.shr(rhs),
981 y: self.y.shr(rhs),
982 }
983 }
984 }
985
986 impl Shl<u32> for U64Vec2 {
987 type Output = Self;
988 #[inline]
989 fn shl(self, rhs: u32) -> Self::Output {
990 Self {
991 x: self.x.shl(rhs),
992 y: self.y.shl(rhs),
993 }
994 }
995 }
996
997 impl Shr<u32> for U64Vec2 {
998 type Output = Self;
999 #[inline]
1000 fn shr(self, rhs: u32) -> Self::Output {
1001 Self {
1002 x: self.x.shr(rhs),
1003 y: self.y.shr(rhs),
1004 }
1005 }
1006 }
1007
1008 impl Shl<u64> for U64Vec2 {
1009 type Output = Self;
1010 #[inline]
1011 fn shl(self, rhs: u64) -> Self::Output {
1012 Self {
1013 x: self.x.shl(rhs),
1014 y: self.y.shl(rhs),
1015 }
1016 }
1017 }
1018
1019 impl Shr<u64> for U64Vec2 {
1020 type Output = Self;
1021 #[inline]
1022 fn shr(self, rhs: u64) -> Self::Output {
1023 Self {
1024 x: self.x.shr(rhs),
1025 y: self.y.shr(rhs),
1026 }
1027 }
1028 }
1029
1030 impl Shl<crate::IVec2> for U64Vec2 {
1031 type Output = Self;
1032 #[inline]
1033 fn shl(self, rhs: crate::IVec2) -> Self::Output {
1034 Self {
1035 x: self.x.shl(rhs.x),
1036 y: self.y.shl(rhs.y),
1037 }
1038 }
1039 }
1040
1041 impl Shr<crate::IVec2> for U64Vec2 {
1042 type Output = Self;
1043 #[inline]
1044 fn shr(self, rhs: crate::IVec2) -> Self::Output {
1045 Self {
1046 x: self.x.shr(rhs.x),
1047 y: self.y.shr(rhs.y),
1048 }
1049 }
1050 }
1051
1052 impl Shl<crate::UVec2> for U64Vec2 {
1053 type Output = Self;
1054 #[inline]
1055 fn shl(self, rhs: crate::UVec2) -> Self::Output {
1056 Self {
1057 x: self.x.shl(rhs.x),
1058 y: self.y.shl(rhs.y),
1059 }
1060 }
1061 }
1062
1063 impl Shr<crate::UVec2> for U64Vec2 {
1064 type Output = Self;
1065 #[inline]
1066 fn shr(self, rhs: crate::UVec2) -> Self::Output {
1067 Self {
1068 x: self.x.shr(rhs.x),
1069 y: self.y.shr(rhs.y),
1070 }
1071 }
1072 }
1073
1074 impl Index<usize> for U64Vec2 {
1075 type Output = u64;
1076 #[inline]
1077 fn index(&self, index: usize) -> &Self::Output {
1078 match index {
1079 0 => &self.x,
1080 1 => &self.y,
1081 _ => panic!("index out of bounds"),
1082 }
1083 }
1084 }
1085
1086 impl IndexMut<usize> for U64Vec2 {
1087 #[inline]
1088 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
1089 match index {
1090 0 => &mut self.x,
1091 1 => &mut self.y,
1092 _ => panic!("index out of bounds"),
1093 }
1094 }
1095 }
1096
1097 #[cfg(not(target_arch = "spirv"))]
1098 impl fmt::Display for U64Vec2 {
1099 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1100 write!(f, "[{}, {}]", self.x, self.y)
1101 }
1102 }
1103
1104 #[cfg(not(target_arch = "spirv"))]
1105 impl fmt::Debug for U64Vec2 {
1106 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1107 fmt.debug_tuple(stringify!(U64Vec2))
1108 .field(&self.x)
1109 .field(&self.y)
1110 .finish()
1111 }
1112 }
1113
1114 impl From<[u64; 2]> for U64Vec2 {
1115 #[inline]
1116 fn from(a: [u64; 2]) -> Self {
1117 Self::new(a[0], a[1])
1118 }
1119 }
1120
1121 impl From<U64Vec2> for [u64; 2] {
1122 #[inline]
1123 fn from(v: U64Vec2) -> Self {
1124 [v.x, v.y]
1125 }
1126 }
1127
1128 impl From<(u64, u64)> for U64Vec2 {
1129 #[inline]
1130 fn from(t: (u64, u64)) -> Self {
1131 Self::new(t.0, t.1)
1132 }
1133 }
1134
1135 impl From<U64Vec2> for (u64, u64) {
1136 #[inline]
1137 fn from(v: U64Vec2) -> Self {
1138 (v.x, v.y)
1139 }
1140 }
1141
1142 impl From<U16Vec2> for U64Vec2 {
1143 #[inline]
1144 fn from(v: U16Vec2) -> Self {
1145 Self::new(u64::from(v.x), u64::from(v.y))
1146 }
1147 }
1148
1149 impl From<UVec2> for U64Vec2 {
1150 #[inline]
1151 fn from(v: UVec2) -> Self {
1152 Self::new(u64::from(v.x), u64::from(v.y))
1153 }
1154 }
1155
1156 impl TryFrom<I16Vec2> for U64Vec2 {
1157 type Error = core::num::TryFromIntError;
1158
1159 #[inline]
1160 fn try_from(v: I16Vec2) -> Result<Self, Self::Error> {
1161 Ok(Self::new(u64::try_from(v.x)?, u64::try_from(v.y)?))
1162 }
1163 }
1164
1165 impl TryFrom<IVec2> for U64Vec2 {
1166 type Error = core::num::TryFromIntError;
1167
1168 #[inline]
1169 fn try_from(v: IVec2) -> Result<Self, Self::Error> {
1170 Ok(Self::new(u64::try_from(v.x)?, u64::try_from(v.y)?))
1171 }
1172 }
1173
1174 impl TryFrom<I64Vec2> for U64Vec2 {
1175 type Error = core::num::TryFromIntError;
1176
1177 #[inline]
1178 fn try_from(v: I64Vec2) -> Result<Self, Self::Error> {
1179 Ok(Self::new(u64::try_from(v.x)?, u64::try_from(v.y)?))
1180 }
1181 }
1182
1183 impl From<BVec2> for U64Vec2 {
1184 #[inline]
1185 fn from(v: BVec2) -> Self {
1186 Self::new(u64::from(v.x), u64::from(v.y))
1187 }
1188 }