From 6c2e28d20e498526d1c6d624b4018e9392d0fb80 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 28 Apr 2020 01:12:27 +0200 Subject: Implement `std::ops::Sub` for `Point` --- core/src/point.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/src/point.rs') diff --git a/core/src/point.rs b/core/src/point.rs index 2b5ad154..a31bf967 100644 --- a/core/src/point.rs +++ b/core/src/point.rs @@ -67,3 +67,11 @@ impl std::ops::Sub for Point { } } } + +impl std::ops::Sub for Point { + type Output = Vector; + + fn sub(self, point: Point) -> Vector { + Vector::new(self.x - point.x, self.y - point.y) + } +} -- cgit From 20d79a43cce5a1bf0cb48a7668ac90d0ac82dfdc Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 28 Apr 2020 03:06:35 +0200 Subject: Implement `Default` for `Point` --- core/src/point.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/point.rs') diff --git a/core/src/point.rs b/core/src/point.rs index a31bf967..3714aa2f 100644 --- a/core/src/point.rs +++ b/core/src/point.rs @@ -1,7 +1,7 @@ use crate::Vector; /// A 2D point. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct Point { /// The X coordinate. pub x: f32, -- cgit