From 1cfa40852822899db8ddb1a42268e88569ecf3d0 Mon Sep 17 00:00:00 2001 From: Xirdus Date: Fri, 1 Aug 2014 22:59:43 +0200 Subject: [PATCH 1/2] implemented Clone trait for Surface --- src/sdl/video.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sdl/video.rs b/src/sdl/video.rs index 97fdede..5e00744 100644 --- a/src/sdl/video.rs +++ b/src/sdl/video.rs @@ -190,6 +190,21 @@ impl Drop for Surface { } } +impl Clone for Surface { + fn clone(&self) -> Surface { + if !self.owned { + Surface{ raw: self.raw, owned: false } + } + else { + let raw = unsafe { ll::SDL_ConvertSurface(self.raw, (*self.raw).format, (*self.raw).flags) }; + if raw.is_null() { // this should never happen, since self.raw, format and flags are proven correct + fail!("couldn't clone surface: {}", get_error()); + } + Surface{ raw: raw, owned: true } + } + } +} + #[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct Palette { From 378105e23eb8d64da1cdb3210d318c9702b6f6f7 Mon Sep 17 00:00:00 2001 From: Xirdus Date: Sun, 17 Aug 2014 19:28:54 +0200 Subject: [PATCH 2/2] added Clone trait for event::Key --- src/sdl/event.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/event.rs b/src/sdl/event.rs index c0d50ee..c9c9f58 100644 --- a/src/sdl/event.rs +++ b/src/sdl/event.rs @@ -225,7 +225,7 @@ pub enum RepeatInterval { CustomRepeatInterval(int) } -#[deriving(PartialEq, Eq, FromPrimitive, PartialOrd, Ord)] +#[deriving(PartialEq, Eq, FromPrimitive, PartialOrd, Ord, Clone)] pub enum Key { UnknownKey = 0, BackspaceKey = 8,