diff --git a/src/sdl2/rect.rs b/src/sdl2/rect.rs index e0db90bb..308a0bef 100644 --- a/src/sdl2/rect.rs +++ b/src/sdl2/rect.rs @@ -4,7 +4,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::ops::{Deref, DerefMut, Add, BitAnd, BitOr, Div, Mul, Neg, Sub}; use std::convert::{AsRef, AsMut}; /// The maximal integer value that can be used for rectangles. @@ -439,6 +439,20 @@ impl Deref for Rect { } } +impl DerefMut for Rect { + /// # Example + /// + /// ```rust + /// use sdl2::rect::Rect; + /// let mut rect = Rect::new(2, 3, 4, 5); + /// rect.x = 60; + /// assert_eq!(60, rect.x); + /// ``` + fn deref_mut(&mut self) -> &mut ll::SDL_Rect { + &mut 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)