add Into<ggez::Rect> for our internal Rect<T>

This commit is contained in:
Alula 2020-09-10 12:26:24 +02:00
parent b72d0451a6
commit 41f72f3c7a
No known key found for this signature in database
GPG Key ID: 3E00485503A1D8BA
1 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,4 @@
use num_traits::Num;
use num_traits::{Num, AsPrimitive};
use crate::bitfield;
@ -215,3 +215,12 @@ impl<T: Num + Copy> Rect<T> {
}
}
}
impl<T: Num + Copy + AsPrimitive<f32>> Into<crate::ggez::graphics::Rect> for Rect<T> {
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_())
}
}