diff --git a/src/utils/geometry.rs b/src/utils/geometry.rs index 50a84e2..80b6823 100644 --- a/src/utils/geometry.rs +++ b/src/utils/geometry.rs @@ -18,7 +18,7 @@ pub struct Buffer; pub struct Raw; pub trait Coordinate: - Sized + Add + Sub + PartialOrd + Default + Copy + std::fmt::Debug + Sized + Add + Sub + PartialOrd + Default + Copy + fmt::Debug { fn downscale(self, scale: Self) -> Self; fn upscale(self, scale: Self) -> Self; @@ -637,9 +637,16 @@ impl AddAssign for Size { } } -impl SubAssign for Size { +impl SubAssign for Size { #[inline] fn sub_assign(&mut self, rhs: Self) { + debug_assert!( + self.w >= rhs.w && self.h >= rhs.h, + "Attempting to subtract bigger from smaller size: {:?} - {:?}", + (&self.w, &self.h), + (&rhs.w, &rhs.h), + ); + self.w -= rhs.w; self.h -= rhs.h }