Merge pull request #68 from gwilymk/div-assign-for-vector2d

Implement divassign for vector 2d
This commit is contained in:
Corwin 2021-06-12 15:17:21 +01:00 committed by GitHub
commit 04e616a1bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -491,6 +491,14 @@ impl<T: Number, U: Number + Into<T>> Div<U> for Vector2D<T> {
}
}
impl<T: Number, U: Number + Into<T>> DivAssign<U> for Vector2D<T> {
fn div_assign(&mut self, rhs: U) {
let result = *self / rhs;
self.x = result.x;
self.y = result.y;
}
}
#[test_case]
fn test_vector_multiplication_and_division(_gba: &mut super::Gba) {
let a: Vector2D<i32> = (1, 2).into();