From c26650a72954cb2579b080444feede2c1137a26d Mon Sep 17 00:00:00 2001
From: Erin <sylphofelectricity@gmail.com>
Date: Sun, 5 Nov 2017 20:42:33 -0600
Subject: [PATCH] textium: rect: numcast

lol there was a bug in this and it fucking sucked
---
 textium/src/geometry.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

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<T> From<rusttype::Rect<T>> for Rect<T> where T: Sub<Output=T> + Copy {
         }
     }
 }
+
+impl<S> Rect<S> where S: NumCast + Copy {
+    pub fn cast<T>(&self) -> Rect<T> 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<T> {