mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Add DerefMut for Rect on ll::SDL_Rect (#599)
This commit is contained in:
+15
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user