@@ -38,38 +38,38 @@ impl Vec2 {
38
38
39
39
/// Creates a new `Vec2`.
40
40
#[ inline]
41
- pub fn new ( x : f32 , y : f32 ) -> Vec2 {
42
- Vec2 ( x, y)
41
+ pub fn new ( x : f32 , y : f32 ) -> Self {
42
+ Self ( x, y)
43
43
}
44
44
45
45
/// Creates a `Vec2` with all elements set to `0.0`.
46
46
#[ inline]
47
- pub fn zero ( ) -> Vec2 {
47
+ pub fn zero ( ) -> Self {
48
48
Self :: splat ( 0.0 )
49
49
}
50
50
51
51
/// Creates a `Vec2` with all elements set to `1.0`.
52
52
#[ inline]
53
- pub fn one ( ) -> Vec2 {
53
+ pub fn one ( ) -> Self {
54
54
Self :: splat ( 1.0 )
55
55
}
56
56
57
57
/// Creates a `Vec2` with values `[x: 1.0, y: 0.0]`.
58
58
#[ inline]
59
- pub fn unit_x ( ) -> Vec2 {
59
+ pub fn unit_x ( ) -> Self {
60
60
Self :: new ( 1.0 , 0.0 )
61
61
}
62
62
63
63
/// Creates a `Vec2` with values `[x: 0.0, y: 1.0]`.
64
64
#[ inline]
65
- pub fn unit_y ( ) -> Vec2 {
65
+ pub fn unit_y ( ) -> Self {
66
66
Self :: new ( 0.0 , 1.0 )
67
67
}
68
68
69
69
/// Creates a `Vec2` with all elements set to `v`.
70
70
#[ inline]
71
- pub fn splat ( v : f32 ) -> Vec2 {
72
- Vec2 ( v, v)
71
+ pub fn splat ( v : f32 ) -> Self {
72
+ Self ( v, v)
73
73
}
74
74
75
75
/// Creates a `Vec3` from `self` and the given `z` value.
@@ -116,7 +116,7 @@ impl Vec2 {
116
116
117
117
/// Computes the dot product of `self` and `other`.
118
118
#[ inline]
119
- pub fn dot ( self , other : Vec2 ) -> f32 {
119
+ pub fn dot ( self , other : Self ) -> f32 {
120
120
( self . 0 * other. 0 ) + ( self . 1 * other. 1 )
121
121
}
122
122
@@ -153,7 +153,7 @@ impl Vec2 {
153
153
///
154
154
/// For valid results, `self` must _not_ be of length zero.
155
155
#[ inline]
156
- pub fn normalize ( self ) -> Vec2 {
156
+ pub fn normalize ( self ) -> Self {
157
157
self * self . length_recip ( )
158
158
}
159
159
@@ -163,8 +163,8 @@ impl Vec2 {
163
163
/// `[x: min(x1, x2), y: min(y1, y2)]`,
164
164
/// taking the minimum of each element individually.
165
165
#[ inline]
166
- pub fn min ( self , other : Vec2 ) -> Vec2 {
167
- Vec2 ( self . 0 . min ( other. 0 ) , self . 1 . min ( other. 1 ) )
166
+ pub fn min ( self , other : Self ) -> Self {
167
+ Self ( self . 0 . min ( other. 0 ) , self . 1 . min ( other. 1 ) )
168
168
}
169
169
170
170
/// Returns the vertical maximum of `self` and `other`.
@@ -173,8 +173,8 @@ impl Vec2 {
173
173
/// `[x: max(x1, x2), y: max(y1, y2)]`,
174
174
/// taking the maximum of each element individually.
175
175
#[ inline]
176
- pub fn max ( self , other : Vec2 ) -> Vec2 {
177
- Vec2 ( self . 0 . max ( other. 0 ) , self . 1 . max ( other. 1 ) )
176
+ pub fn max ( self , other : Self ) -> Self {
177
+ Self ( self . 0 . max ( other. 0 ) , self . 1 . max ( other. 1 ) )
178
178
}
179
179
180
180
/// Returns the horizontal minimum of `self`'s elements.
@@ -255,22 +255,22 @@ impl Vec2 {
255
255
256
256
/// The perpendicular dot product of the vector and `other`.
257
257
#[ inline]
258
- pub fn perp_dot ( self , other : Vec2 ) -> f32 {
258
+ pub fn perp_dot ( self , other : Self ) -> f32 {
259
259
( self . 0 * other. 1 ) - ( self . 1 * other. 0 )
260
260
}
261
261
}
262
262
263
263
impl Div < Vec2 > for Vec2 {
264
264
type Output = Self ;
265
265
#[ inline]
266
- fn div ( self , other : Vec2 ) -> Self {
266
+ fn div ( self , other : Self ) -> Self {
267
267
Self ( self . 0 / other. 0 , self . 1 / other. 1 )
268
268
}
269
269
}
270
270
271
271
impl DivAssign < Vec2 > for Vec2 {
272
272
#[ inline]
273
- fn div_assign ( & mut self , other : Vec2 ) {
273
+ fn div_assign ( & mut self , other : Self ) {
274
274
self . 0 /= other. 0 ;
275
275
self . 1 /= other. 1 ;
276
276
}
@@ -303,14 +303,14 @@ impl Div<Vec2> for f32 {
303
303
impl Mul < Vec2 > for Vec2 {
304
304
type Output = Self ;
305
305
#[ inline]
306
- fn mul ( self , other : Vec2 ) -> Self {
306
+ fn mul ( self , other : Self ) -> Self {
307
307
Self ( self . 0 * other. 0 , self . 1 * other. 1 )
308
308
}
309
309
}
310
310
311
311
impl MulAssign < Vec2 > for Vec2 {
312
312
#[ inline]
313
- fn mul_assign ( & mut self , other : Vec2 ) {
313
+ fn mul_assign ( & mut self , other : Self ) {
314
314
self . 0 *= other. 0 ;
315
315
self . 1 *= other. 1 ;
316
316
}
@@ -359,14 +359,14 @@ impl AddAssign for Vec2 {
359
359
impl Sub for Vec2 {
360
360
type Output = Self ;
361
361
#[ inline]
362
- fn sub ( self , other : Vec2 ) -> Self {
362
+ fn sub ( self , other : Self ) -> Self {
363
363
Self ( self . 0 - other. 0 , self . 1 - other. 1 )
364
364
}
365
365
}
366
366
367
367
impl SubAssign for Vec2 {
368
368
#[ inline]
369
- fn sub_assign ( & mut self , other : Vec2 ) {
369
+ fn sub_assign ( & mut self , other : Self ) {
370
370
self . 0 -= other. 0 ;
371
371
self . 1 -= other. 1 ;
372
372
}
0 commit comments