diff options
| author | 2020-03-07 23:45:54 +0100 | |
|---|---|---|
| committer | 2020-03-07 23:45:54 +0100 | |
| commit | b74e7e7353d69ffb54cf0c0f0574ea7abf0f3a68 (patch) | |
| tree | d05e074ad1a57309ae1ed09f49fee1cbb78a6ea6 /core | |
| parent | 37f0d97159d81dbd4801e287a06f4e243e483269 (diff) | |
| download | iced-b74e7e7353d69ffb54cf0c0f0574ea7abf0f3a68.tar.gz iced-b74e7e7353d69ffb54cf0c0f0574ea7abf0f3a68.tar.bz2 iced-b74e7e7353d69ffb54cf0c0f0574ea7abf0f3a68.zip | |
Implement `Primitive::Cached`
Diffstat (limited to '')
| -rw-r--r-- | core/src/point.rs | 11 | ||||
| -rw-r--r-- | core/src/vector.rs | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/core/src/point.rs b/core/src/point.rs index b9a8149c..b55f5099 100644 --- a/core/src/point.rs +++ b/core/src/point.rs @@ -46,3 +46,14 @@ impl std::ops::Add<Vector> for Point { } } } + +impl std::ops::Sub<Vector> for Point { + type Output = Self; + + fn sub(self, vector: Vector) -> Self { + Self { + x: self.x - vector.x, + y: self.y - vector.y, + } + } +} diff --git a/core/src/vector.rs b/core/src/vector.rs index 4c1cbfab..a75053a0 100644 --- a/core/src/vector.rs +++ b/core/src/vector.rs @@ -32,6 +32,17 @@ where } } +impl<T> std::ops::Sub for Vector<T> +where + T: std::ops::Sub<Output = T>, +{ + type Output = Self; + + fn sub(self, b: Self) -> Self { + Self::new(self.x - b.x, self.y - b.y) + } +} + impl<T> Default for Vector<T> where T: Default, |
