diff --git a/src/vector2d.rs b/src/vector2d.rs index d89bb15..742f794 100644 --- a/src/vector2d.rs +++ b/src/vector2d.rs @@ -1,7 +1,7 @@ use std::cmp::Eq; use std::fmt::Debug; use std::hash::Hash; -use std::ops::{Add, Mul}; +use std::ops::{Add, Mul, Sub}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Vector2D { @@ -81,6 +81,17 @@ impl, U> Add for Vector2D { } } +impl, U> Sub for Vector2D { + type Output = Vector2D; + + fn sub(self, rhs: Self) -> Self::Output { + Vector2D { + x: self.x - rhs.x, + y: self.y - rhs.y, + } + } +} + impl, U> Mul for Vector2D { type Output = Vector2D;