lex_lib/vec2u32/
operators.rs

1use std::ops;
2use super::Vec2u32;
3
4impl ops::Add<Self> for Vec2u32 {
5	type Output = Self;
6	fn add(self, rhs: Self) -> Self {
7		Self{
8			x: self.x + rhs.x,
9			y: self.y + rhs.y
10		}
11	}
12}
13impl ops::Add<u32> for Vec2u32 {
14	type Output = Self;
15	fn add(self, rhs: u32) -> Self {
16		Self{
17			x: self.x + rhs,
18			y: self.y + rhs
19		}
20	}
21}
22
23impl ops::AddAssign<Self> for Vec2u32 {
24	fn add_assign(&mut self, rhs: Self){
25		*self = Self{
26			x: self.x + rhs.x,
27			y: self.y + rhs.y
28		}
29	}
30}
31impl ops::AddAssign<u32> for Vec2u32 {
32	fn add_assign(&mut self, rhs: u32){
33		*self = Self{
34			x: self.x + rhs,
35			y: self.y + rhs
36		}
37	}
38}
39
40impl ops::Div<Self> for Vec2u32 {
41	type Output = Self;
42	fn div(self, rhs: Self) -> Self {
43		Self{
44			x: self.x / rhs.x,
45			y: self.y / rhs.y
46		}
47	}
48}
49impl ops::Div<u32> for Vec2u32 {
50	type Output = Self;
51	fn div(self, rhs: u32) -> Self {
52		Self{
53			x: self.x / rhs,
54			y: self.y / rhs
55		}
56	}
57}
58
59impl ops::DivAssign<Self> for Vec2u32 {
60	fn div_assign(&mut self, rhs: Self){
61		*self = Self{
62			x: self.x / rhs.x,
63			y: self.y / rhs.y
64		}
65	}
66}
67impl ops::DivAssign<u32> for Vec2u32 {
68	fn div_assign(&mut self, rhs: u32){
69		*self = Self{
70			x: self.x / rhs,
71			y: self.y / rhs
72		}
73	}
74}
75
76impl ops::Rem<Self> for Vec2u32 {
77	type Output = Self;
78	fn rem(self, rhs: Self) -> Self {
79		Self{
80			x: self.x % rhs.x,
81			y: self.y % rhs.y
82		}
83	}
84}
85impl ops::Rem<u32> for Vec2u32 {
86	type Output = Self;
87	fn rem(self, rhs: u32) -> Self {
88		Self{
89			x: self.x % rhs,
90			y: self.y % rhs
91		}
92	}
93}
94
95impl ops::RemAssign<Self> for Vec2u32 {
96	fn rem_assign(&mut self, rhs: Self) {
97		*self = Self{
98			x: self.x % rhs.x,
99			y: self.y % rhs.y
100		}
101	}
102}
103impl ops::RemAssign<u32> for Vec2u32 {
104	fn rem_assign(&mut self, rhs: u32) {
105		*self = Self{
106			x: self.x % rhs,
107			y: self.y % rhs
108		}
109	}
110}
111
112impl ops::Sub<Self> for Vec2u32 {
113	type Output = Self;
114	fn sub(self, rhs: Self) -> Self {
115		Self{
116			x: self.x - rhs.x,
117			y: self.y - rhs.y
118		}
119	}
120}
121impl ops::Sub<u32> for Vec2u32 {
122	type Output = Self;
123	fn sub(self, rhs: u32) -> Self {
124		Self{
125			x: self.x - rhs,
126			y: self.y - rhs
127		}
128	}
129}
130
131impl ops::SubAssign<Self> for Vec2u32 {
132	fn sub_assign(&mut self, rhs: Self) {
133		*self = Self{
134			x: self.x - rhs.x,
135			y: self.y - rhs.y
136		}
137	}
138}
139impl ops::SubAssign<u32> for Vec2u32 {
140	fn sub_assign(&mut self, rhs: u32) {
141		*self = Self{
142			x: self.x - rhs,
143			y: self.y - rhs
144		}
145	}
146}