add AsRef and AsMut for Rect on ll::SDL_Rect

Solves #593
This commit is contained in:
Geordon Worley
2017-02-02 19:40:56 +01:00
committed by Cobrand
parent aa6db51f68
commit 8ee975d1be
+13
View File
@@ -5,6 +5,7 @@ use sys::rect as ll;
use std::mem;
use std::ptr;
use std::ops::{Deref, Add, BitAnd, BitOr, Div, Mul, Neg, Sub};
use std::convert::{AsRef, AsMut};
/// The maximal integer value that can be used for rectangles.
///
@@ -450,6 +451,18 @@ impl From<(i32, i32, u32, u32)> for Rect {
}
}
impl AsRef<ll::SDL_Rect> for Rect {
fn as_ref(&self) -> &ll::SDL_Rect {
&self.raw
}
}
impl AsMut<ll::SDL_Rect> for Rect {
fn as_mut(&mut self) -> &mut ll::SDL_Rect {
&mut self.raw
}
}
// Intersection
impl BitAnd<Rect> for Rect {
type Output = Option<Rect>;