Merge pull request #3137 from edwloef/cursor-sub

Implement `Sub<Vector>` for `Cursor`
This commit is contained in:
Héctor 2025-12-04 21:27:57 +01:00 committed by GitHub
commit 44e2087fea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,6 +89,20 @@ impl std::ops::Add<Vector> for Cursor {
}
}
impl std::ops::Sub<Vector> for Cursor {
type Output = Self;
fn sub(self, translation: Vector) -> Self::Output {
match self {
Cursor::Available(point) => Cursor::Available(point - translation),
Cursor::Levitating(point) => {
Cursor::Levitating(point - translation)
}
Cursor::Unavailable => Cursor::Unavailable,
}
}
}
impl std::ops::Mul<Transformation> for Cursor {
type Output = Self;