add From and Into for Rect on ll::SDL_Rect

This commit is contained in:
Geordon Worley
2017-02-02 20:35:22 +01:00
committed by Cobrand
parent 79e3abf7de
commit bf2216eb8a
+12
View File
@@ -453,12 +453,24 @@ impl DerefMut for Rect {
}
}
impl Into<ll::SDL_Rect> for Rect {
fn into(self) -> ll::SDL_Rect {
self.raw
}
}
impl Into<(i32, i32, u32, u32)> for Rect {
fn into(self) -> (i32, i32, u32, u32) {
(self.raw.x, self.raw.y, self.raw.w as u32, self.raw.h as u32)
}
}
impl From<ll::SDL_Rect> for Rect {
fn from(raw: ll::SDL_Rect) -> Rect {
Rect { raw: raw }
}
}
impl From<(i32, i32, u32, u32)> for Rect {
fn from((x, y, width, height): (i32, i32, u32, u32)) -> Rect {
Rect::new(x, y, width, height)