From 262eed55ad34b8c0c80dd107c111f0ac44b6290f Mon Sep 17 00:00:00 2001 From: Siim Kallas Date: Mon, 4 Aug 2014 22:00:44 +0300 Subject: [PATCH] Removed undefined behaviour from pattern matching --- src/sdl2/render.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index d6c92bea..a4d6c17d 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -520,11 +520,11 @@ impl Renderer { self.raw, texture.raw, match src { - Some(rect) => mem::transmute(&rect), + Some(ref rect) => mem::transmute(rect), None => ptr::null() }, match dst { - Some(rect) => mem::transmute(&rect), + Some(ref rect) => mem::transmute(rect), None => ptr::null() } ) @@ -541,16 +541,16 @@ impl Renderer { self.raw, texture.raw, match src { - Some(rect) => mem::transmute(&rect), + Some(ref rect) => mem::transmute(rect), None => ptr::null() }, match dst { - Some(rect) => mem::transmute(&rect), + Some(ref rect) => mem::transmute(rect), None => ptr::null() }, angle as c_double, match center { - Some(point) => mem::transmute(&point), + Some(ref point) => mem::transmute(point), None => ptr::null() }, FromPrimitive::from_i64(flip as i64).unwrap() @@ -564,7 +564,7 @@ impl Renderer { pub fn read_pixels(&self, rect: Option, format: pixels::PixelFormatFlag) -> SdlResult> { unsafe { let (actual_rect, w, h) = match rect { - Some(rect) => (mem::transmute(&rect), rect.w as uint, rect.h as uint), + Some(ref rect) => (mem::transmute(rect), rect.w as uint, rect.h as uint), None => { let (w, h) = try!(self.get_output_size()); (ptr::null(), w as uint, h as uint) @@ -687,7 +687,7 @@ impl Texture { pub fn update(&self, rect: Option, pixel_data: &[u8], pitch: int) -> SdlResult<()> { let ret = unsafe { let actual_rect = match rect { - Some(rect) => mem::transmute(&rect), + Some(ref rect) => mem::transmute(rect), None => ptr::null() }; @@ -702,7 +702,7 @@ impl Texture { let q = try!(self.query()); unsafe { let actual_rect = match rect { - Some(rect) => mem::transmute(&rect), + Some(ref rect) => mem::transmute(rect), None => ptr::null() };