lex_lib/vec2f64/
operators.rs

1use std::ops;
2use super::Vec2f64;
3
4impl ops::Add<Self> for Vec2f64 {
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<f64> for Vec2f64 {
14	type Output = Self;
15	fn add(self, rhs: f64) -> Self {
16		Self{
17			x: self.x + rhs,
18			y: self.y + rhs
19		}
20	}
21}
22
23impl ops::AddAssign<Self> for Vec2f64 {
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<f64> for Vec2f64 {
32	fn add_assign(&mut self, rhs: f64){
33		*self = Self{
34			x: self.x + rhs,
35			y: self.y + rhs
36		}
37	}
38}
39
40impl ops::Div<Self> for Vec2f64 {
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<f64> for Vec2f64 {
50	type Output = Self;
51	fn div(self, rhs: f64) -> Self {
52		Self{
53			x: self.x / rhs,
54			y: self.y / rhs
55		}
56	}
57}
58
59impl ops::DivAssign<Self> for Vec2f64 {
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<f64> for Vec2f64 {
68	fn div_assign(&mut self, rhs: f64){
69		*self = Self{
70			x: self.x / rhs,
71			y: self.y / rhs
72		}
73	}
74}
75
76impl ops::Neg for Vec2f64 {
77	type Output = Self;
78	fn neg(self) -> Self {
79		Self{
80			x: -self.x,
81			y: -self.y,
82		}
83	}
84}
85
86impl ops::Rem<Self> for Vec2f64 {
87	type Output = Self;
88	fn rem(self, rhs: Self) -> Self {
89		Self{
90			x: self.x % rhs.x,
91			y: self.y % rhs.y
92		}
93	}
94}
95impl ops::Rem<f64> for Vec2f64 {
96	type Output = Self;
97	fn rem(self, rhs: f64) -> Self {
98		Self{
99			x: self.x % rhs,
100			y: self.y % rhs
101		}
102	}
103}
104
105impl ops::RemAssign<Self> for Vec2f64 {
106	fn rem_assign(&mut self, rhs: Self) {
107		*self = Self{
108			x: self.x % rhs.x,
109			y: self.y % rhs.y
110		}
111	}
112}
113impl ops::RemAssign<f64> for Vec2f64 {
114	fn rem_assign(&mut self, rhs: f64) {
115		*self = Self{
116			x: self.x % rhs,
117			y: self.y % rhs
118		}
119	}
120}
121
122impl ops::Sub<Self> for Vec2f64 {
123	type Output = Self;
124	fn sub(self, rhs: Self) -> Self {
125		Self{
126			x: self.x - rhs.x,
127			y: self.y - rhs.y
128		}
129	}
130}
131impl ops::Sub<f64> for Vec2f64 {
132	type Output = Self;
133	fn sub(self, rhs: f64) -> Self {
134		Self{
135			x: self.x - rhs,
136			y: self.y - rhs
137		}
138	}
139}
140
141impl ops::SubAssign<Self> for Vec2f64 {
142	fn sub_assign(&mut self, rhs: Self) {
143		*self = Self{
144			x: self.x - rhs.x,
145			y: self.y - rhs.y
146		}
147	}
148}
149impl ops::SubAssign<f64> for Vec2f64 {
150	fn sub_assign(&mut self, rhs: f64) {
151		*self = Self{
152			x: self.x - rhs,
153			y: self.y - rhs
154		}
155	}
156}