From 41f72f3c7a7d893f9684a0ce866ee36666ceee66 Mon Sep 17 00:00:00 2001 From: Alula Date: Thu, 10 Sep 2020 12:26:24 +0200 Subject: [PATCH] add Into for our internal Rect --- src/common.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index 62568d3..77ae287 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,4 +1,4 @@ -use num_traits::Num; +use num_traits::{Num, AsPrimitive}; use crate::bitfield; @@ -215,3 +215,12 @@ impl Rect { } } } + +impl> Into for Rect { + fn into(self) -> crate::ggez::graphics::Rect { + crate::ggez::graphics::Rect::new(self.top.as_(), + self.left.as_(), + self.bottom.sub(self.top).as_(), + self.right.sub(self.left).as_()) + } +}