Merge pull request #129 from corwinkuiper/touches-reference

add useful derives
This commit is contained in:
Corwin 2021-10-30 10:27:48 +01:00 committed by GitHub
commit ac64d0a36f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -639,6 +639,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> From<Vector2D<I>> for Vector2
}
}
#[derive(PartialEq, Eq, Clone)]
pub struct Rect<T: Number> {
pub position: Vector2D<T>,
pub size: Vector2D<T>,
@ -656,7 +657,7 @@ impl<T: Number> Rect<T> {
&& point.y < self.position.y + self.size.y
}
pub fn touches(self, other: Rect<T>) -> bool {
pub fn touches(&self, other: Rect<T>) -> bool {
self.position.x < other.position.x + other.size.x
&& self.position.x + self.size.x > other.position.x
&& self.position.y < other.position.y + other.size.y