core/portable-simd/crates/core_simd/src/ops/
assign.rs1use super::*;
4use core::ops::{AddAssign, MulAssign}; use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign}; use core::ops::{DivAssign, RemAssign, SubAssign}; use core::ops::{ShlAssign, ShrAssign}; macro_rules! assign_ops {
12 ($(impl<T, U, const N: usize> $assignTrait:ident<U> for Simd<T, N>
13 where
14 Self: $trait:ident,
15 {
16 fn $assign_call:ident(rhs: U) {
17 $call:ident
18 }
19 })*) => {
20 $(impl<T, U, const N: usize> $assignTrait<U> for Simd<T, N>
21 where
22 Self: $trait<U, Output = Self>,
23 T: SimdElement,
24 LaneCount<N>: SupportedLaneCount,
25 {
26 #[inline]
27 fn $assign_call(&mut self, rhs: U) {
28 *self = self.$call(rhs);
29 }
30 })*
31 }
32}
33
34assign_ops! {
35 impl<T, U, const N: usize> AddAssign<U> for Simd<T, N>
37 where
38 Self: Add,
39 {
40 fn add_assign(rhs: U) {
41 add
42 }
43 }
44
45 impl<T, U, const N: usize> MulAssign<U> for Simd<T, N>
46 where
47 Self: Mul,
48 {
49 fn mul_assign(rhs: U) {
50 mul
51 }
52 }
53
54 impl<T, U, const N: usize> SubAssign<U> for Simd<T, N>
55 where
56 Self: Sub,
57 {
58 fn sub_assign(rhs: U) {
59 sub
60 }
61 }
62
63 impl<T, U, const N: usize> DivAssign<U> for Simd<T, N>
64 where
65 Self: Div,
66 {
67 fn div_assign(rhs: U) {
68 div
69 }
70 }
71 impl<T, U, const N: usize> RemAssign<U> for Simd<T, N>
72 where
73 Self: Rem,
74 {
75 fn rem_assign(rhs: U) {
76 rem
77 }
78 }
79
80 impl<T, U, const N: usize> BitAndAssign<U> for Simd<T, N>
82 where
83 Self: BitAnd,
84 {
85 fn bitand_assign(rhs: U) {
86 bitand
87 }
88 }
89
90 impl<T, U, const N: usize> BitOrAssign<U> for Simd<T, N>
91 where
92 Self: BitOr,
93 {
94 fn bitor_assign(rhs: U) {
95 bitor
96 }
97 }
98
99 impl<T, U, const N: usize> BitXorAssign<U> for Simd<T, N>
100 where
101 Self: BitXor,
102 {
103 fn bitxor_assign(rhs: U) {
104 bitxor
105 }
106 }
107
108 impl<T, U, const N: usize> ShlAssign<U> for Simd<T, N>
109 where
110 Self: Shl,
111 {
112 fn shl_assign(rhs: U) {
113 shl
114 }
115 }
116
117 impl<T, U, const N: usize> ShrAssign<U> for Simd<T, N>
118 where
119 Self: Shr,
120 {
121 fn shr_assign(rhs: U) {
122 shr
123 }
124 }
125}