diff --git a/textium/src/geometry.rs b/textium/src/geometry.rs index 8ab5189..9d4d6be 100644 --- a/textium/src/geometry.rs +++ b/textium/src/geometry.rs @@ -80,6 +80,19 @@ impl From> for Rect where T: Sub + Copy { } } } + +impl Rect where S: NumCast + Copy { + pub fn cast(&self) -> Rect where T: NumCast { + Rect { + x: NumCast::from(self.x).unwrap(), + y: NumCast::from(self.y).unwrap(), + w: NumCast::from(self.w).unwrap(), + h: NumCast::from(self.h).unwrap(), + } + } +} + + /// A 2D vector #[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)] pub struct Vec2 {