From 878f6051bcf38a6e2ac7fc39b0076119434f4349 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 9 Jan 2025 18:33:34 +0100 Subject: [PATCH] Implement `Sub` between two `Point`s --- experiments/2024-12-09/src/math/point.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/experiments/2024-12-09/src/math/point.rs b/experiments/2024-12-09/src/math/point.rs index 396ebdb1a..9dbc2f8dc 100644 --- a/experiments/2024-12-09/src/math/point.rs +++ b/experiments/2024-12-09/src/math/point.rs @@ -30,3 +30,15 @@ where Self { coords } } } + +impl ops::Sub

for Point +where + P: Into>, +{ + type Output = Vector; + + fn sub(self, other: P) -> Self::Output { + let other = other.into(); + self.coords - other.coords + } +}