diff --git a/src/codegen/branchify.rs b/src/codegen/branchify.rs index fb09d40a..b33c5544 100644 --- a/src/codegen/branchify.rs +++ b/src/codegen/branchify.rs @@ -49,7 +49,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec { assert!(branch.result.is_none()); - branch.result = Some(result.to_owned()); + branch.result = Some(result.to_string()); }, } }; @@ -132,7 +132,7 @@ pub fn generate_branchified_method( wf!(" _ => return None,"); wf!("\\};"); wf!("// OK, that didn't pan out. Let's read the rest and see what we get."); - wf!("let mut s = s.to_owned();"); + wf!("let mut s = s.to_string();"); wf!("s.push_char(next_byte as char);"); wf!("loop \\{"); wf!(" match {} \\{", read_call); diff --git a/src/codegen/keycode.rs b/src/codegen/keycode.rs index 4f8db1e3..e767b448 100644 --- a/src/codegen/keycode.rs +++ b/src/codegen/keycode.rs @@ -7,7 +7,7 @@ struct Key { ident: &'static str, } -impl Ord for Key { +impl PartialOrd for Key { fn lt (&self, other: &Key) -> bool { if self.code < other.code { true @@ -17,7 +17,7 @@ impl Ord for Key { } } -impl Eq for Key { +impl PartialEq for Key { fn eq (&self, other: &Key) -> bool { if self.code == other.code { true @@ -39,14 +39,14 @@ impl TotalOrd for Key { impl TotalEq for Key { } - +#[allow(non_snake_case_functions)] fn Key(code: uint, ident: &'static str) -> Key { Key { code: code, ident: ident } } impl Key { fn ident(&self) -> String { - self.ident.to_owned() + self.ident.to_string() } fn padded_ident(&self) -> String { @@ -310,7 +310,7 @@ use std::hash::sip::SipState; use std::num::FromPrimitive; use std::num::ToPrimitive; -#[deriving(Eq, TotalEq, Show)] +#[deriving(PartialEq, TotalEq, Show)] pub enum KeyCode { ".as_bytes())); for &entry in entries.iter() { @@ -321,10 +321,10 @@ pub enum KeyCode { } impl Hash for KeyCode { - #[inline] + #[inline] fn hash(&self, state: &mut SipState) { self.code().hash(state); - } + } } impl KeyCode { diff --git a/src/codegen/scancode.rs b/src/codegen/scancode.rs index 34937ee0..4b65d90d 100644 --- a/src/codegen/scancode.rs +++ b/src/codegen/scancode.rs @@ -7,7 +7,7 @@ struct ScanCode { ident: &'static str, } -impl Ord for ScanCode { +impl PartialOrd for ScanCode { fn lt (&self, other: &ScanCode) -> bool { if self.code < other.code { true @@ -17,7 +17,7 @@ impl Ord for ScanCode { } } -impl Eq for ScanCode { +impl PartialEq for ScanCode { fn eq (&self, other: &ScanCode) -> bool { if self.code == other.code { true @@ -39,13 +39,14 @@ impl TotalOrd for ScanCode { impl TotalEq for ScanCode { } +#[allow(non_snake_case_functions)] fn ScanCode(code: uint, ident: &'static str) -> ScanCode { ScanCode { code: code, ident: ident } } impl ScanCode { fn ident(&self) -> String { - self.ident.to_owned() + self.ident.to_string() } fn padded_ident(&self) -> String { @@ -316,7 +317,7 @@ use std::hash::sip::SipState; use std::num::FromPrimitive; use std::num::ToPrimitive; -#[deriving(Eq, TotalEq, Show)] +#[deriving(PartialEq, TotalEq, Show)] pub enum ScanCode { ".as_bytes())); for &entry in entries.iter() { @@ -341,7 +342,7 @@ impl ScanCode { for &entry in entries.iter() { try!(out.write(format!(" {} => {},\n", entry.padded_ident(), entry.code).container_as_bytes())); } - + try!(out.write(" } } @@ -380,7 +381,7 @@ impl FromPrimitive for ScanCode { for &entry in entries.iter() { try!(out.write(format!(" {} => Some({}),\n", entry.code, entry.ident()).container_as_bytes())); } - + try!(out.write(" _ => { Some(UnknownScanCode) } } @@ -389,7 +390,7 @@ impl FromPrimitive for ScanCode { try!(out.write(" }".as_bytes())); - + try!(out.flush()); Ok(()) } diff --git a/src/sdl2/audio.rs b/src/sdl2/audio.rs index 42425216..79e4278e 100644 --- a/src/sdl2/audio.rs +++ b/src/sdl2/audio.rs @@ -142,7 +142,7 @@ pub static AudioS32SYS : AudioFormat = ll::AUDIO_S32SYS; pub static AudioF32SYS : AudioFormat = ll::AUDIO_F32SYS; #[repr(C)] -#[deriving(Clone, Eq, Hash, Show, FromPrimitive)] +#[deriving(Clone, PartialEq, Hash, Show, FromPrimitive)] pub enum AudioStatus { Stopped = ll::SDL_AUDIO_STOPPED as int, Playing = ll::SDL_AUDIO_PLAYING as int, @@ -156,7 +156,7 @@ pub fn get_num_audio_drivers() -> int { pub fn get_audio_driver(index: int) -> String { unsafe { let buf = ll::SDL_GetAudioDriver(index as c_int); - CString::new(buf, false).as_str().unwrap().into_owned() + CString::new(buf, false).as_str().unwrap().into_string() } } @@ -167,11 +167,11 @@ pub fn get_num_audio_devices(iscapture: int) -> int { pub fn get_audio_device_name(index: int, iscapture: int) -> String { unsafe { let buf = ll::SDL_GetAudioDeviceName(index as c_int, iscapture as c_int); - CString::new(buf, false).as_str().unwrap().into_owned() + CString::new(buf, false).as_str().unwrap().into_string() } } -pub fn audio_init(name: &str) -> Result<(), String> { +pub fn audio_init(name: &str) -> SdlResult<()> { let ret = name.with_c_str(|buf| { unsafe { ll::SDL_AudioInit(buf) } }); @@ -189,12 +189,10 @@ pub fn audio_quit() { pub fn get_current_audio_driver() -> String { unsafe { let buf = ll::SDL_GetCurrentAudioDriver(); - CString::new(buf, false).as_str().unwrap().into_owned() + CString::new(buf, false).as_str().unwrap().into_string() } } -// make this same layout as in C -#[repr(C)] pub struct AudioSpec<'a > { pub freq: c_int, pub format: AudioFormat, @@ -316,7 +314,7 @@ impl AudioDevice { } } -#[deriving(Eq)] #[allow(raw_pointer_deriving)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct AudioCVT { raw: *mut ll::SDL_AudioCVT, owned: bool, @@ -354,7 +352,7 @@ impl AudioCVT { unsafe { if (*self.raw).needed != 1 { - return Err("no convertion needed!".into_owned()) + return Err("no convertion needed!".into_string()) } // set len (*self.raw).len = src.len() as c_int; diff --git a/src/sdl2/controller.rs b/src/sdl2/controller.rs index 06948d8a..106eb899 100644 --- a/src/sdl2/controller.rs +++ b/src/sdl2/controller.rs @@ -122,7 +122,7 @@ pub mod ll { } } -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum ControllerAxis { InvalidAxis = ll::SDL_CONTROLLER_AXIS_INVALID, LeftXAxis = ll::SDL_CONTROLLER_AXIS_LEFTX, @@ -145,7 +145,7 @@ pub fn wrap_controller_axis(bitflags: u8) -> ControllerAxis { } } -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum ControllerButton { InvalidButton = ll::SDL_CONTROLLER_BUTTON_INVALID, AButton = ll::SDL_CONTROLLER_BUTTON_A, diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index 9c56311b..49de6d67 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -786,7 +786,7 @@ impl Event { Ok(window) => window, }; - let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::>().as_slice()).into_owned(); + let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::>().as_slice()).into_string(); TextEditingEvent(event.timestamp as uint, window, text, event.start as int, event.length as int) } @@ -799,7 +799,7 @@ impl Event { Ok(window) => window, }; - let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::>().as_slice()).into_owned(); + let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::>().as_slice()).into_string(); TextInputEvent(event.timestamp as uint, window, text) } @@ -1142,7 +1142,7 @@ pub fn push_event(event: Event) -> SdlResult<()> { else { Err(get_error()) } }, None => { - Err("Unsupport event type to push back to queue.".into_owned()) + Err("Unsupport event type to push back to queue.".into_string()) } } } diff --git a/src/sdl2/mouse.rs b/src/sdl2/mouse.rs index 5ed1aa3f..00b897d5 100644 --- a/src/sdl2/mouse.rs +++ b/src/sdl2/mouse.rs @@ -55,7 +55,7 @@ pub mod ll { } } -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum SystemCursor { ArrowCursor = ll::SDL_SYSTEM_CURSOR_ARROW, IBeamCursor = ll::SDL_SYSTEM_CURSOR_IBEAM, @@ -71,7 +71,7 @@ pub enum SystemCursor { HandCursor = ll::SDL_SYSTEM_CURSOR_HAND, } -#[deriving(Eq)] #[allow(raw_pointer_deriving)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct Cursor { raw: *ll::SDL_Cursor, owned: bool @@ -134,7 +134,7 @@ impl Cursor { } } -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum Mouse { LeftMouse, MiddleMouse, @@ -159,7 +159,7 @@ pub fn wrap_mouse(bitflags: u8) -> Mouse { 3 => RightMouse, 4 => X1Mouse, 5 => X2Mouse, - _ => UnknownMouse(bitflags) + _ => UnknownMouse(bitflags) } } diff --git a/src/sdl2/pixels.rs b/src/sdl2/pixels.rs index 1a253671..dcb9b5e6 100644 --- a/src/sdl2/pixels.rs +++ b/src/sdl2/pixels.rs @@ -87,14 +87,14 @@ pub mod ll { pub fn SDL_MapRGBA(format: *SDL_PixelFormat, r: uint8_t, g: uint8_t, b: uint8_t, a: uint8_t) -> uint32_t; } } -#[deriving(Eq)] #[allow(raw_pointer_deriving)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct Palette { raw: *ll::SDL_Palette } impl_raw_accessors!(Palette, *ll::SDL_Palette) -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum Color { RGB(u8, u8, u8), RGBA(u8, u8, u8, u8) @@ -132,7 +132,7 @@ impl rand::Rand for Color { } } -#[deriving(Eq)] #[allow(raw_pointer_deriving)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct PixelFormat { raw: *ll::SDL_PixelFormat } @@ -140,7 +140,7 @@ pub struct PixelFormat { impl_raw_accessors!(PixelFormat, *ll::SDL_PixelFormat) impl_raw_constructor!(PixelFormat -> PixelFormat (raw: *ll::SDL_PixelFormat)) -#[deriving(Eq, Show, FromPrimitive)] +#[deriving(PartialEq, Show, FromPrimitive)] pub enum PixelFormatFlag { Unknown = ll::SDL_PIXELFORMAT_UNKNOWN as int, Index1LSB = ll::SDL_PIXELFORMAT_INDEX1LSB as int, diff --git a/src/sdl2/rect.rs b/src/sdl2/rect.rs index 4b1258f8..50a8b2b5 100644 --- a/src/sdl2/rect.rs +++ b/src/sdl2/rect.rs @@ -6,14 +6,14 @@ use std::mem; use libc::c_int; /// A structure that defines a two dimensional point. -#[deriving(Eq, Clone, Show)] +#[deriving(PartialEq, Clone, Show)] pub struct Point { pub x: i32, pub y: i32 } /// A structure that defines a rectangle, with the origin at the upper left. -#[deriving(Eq, Clone, Show)] +#[deriving(PartialEq, Clone, Show)] pub struct Rect { pub x: i32, pub y: i32, diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index 08a03988..d34313f3 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -143,7 +143,7 @@ pub enum RenderDriverIndex { DriverIndex(int) } -#[deriving(Eq, FromPrimitive)] +#[deriving(PartialEq, FromPrimitive)] pub enum TextureAccess { AccessStatic = ll::SDL_TEXTUREACCESS_STATIC as int, AccessStreaming = ll::SDL_TEXTUREACCESS_STREAMING as int, @@ -157,7 +157,7 @@ bitflags!(flags RendererFlags: u32 { static TargetTexture = ll::SDL_RENDERER_TARGETTEXTURE as u32 }) -#[deriving(Eq)] +#[deriving(PartialEq)] pub struct RendererInfo { pub name: String, pub flags: RendererFlags, @@ -166,7 +166,7 @@ pub struct RendererInfo { pub max_texture_height: int } -#[deriving(Eq, FromPrimitive)] +#[deriving(PartialEq, FromPrimitive)] pub enum BlendMode { BlendNone = ll::SDL_BLENDMODE_NONE as int, BlendBlend = ll::SDL_BLENDMODE_BLEND as int, @@ -174,7 +174,7 @@ pub enum BlendMode { BlendMod = ll::SDL_BLENDMODE_MOD as int } -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum RendererFlip { FlipNone = ll::SDL_FLIP_NONE as int, FlipHorizontal = ll::SDL_FLIP_HORIZONTAL as int, @@ -201,7 +201,7 @@ impl RendererInfo { } } -#[deriving(Eq)] #[allow(raw_pointer_deriving)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct Renderer { raw: *ll::SDL_Renderer, parent: Option, @@ -274,8 +274,8 @@ impl Renderer { pub fn get_parent<'a>(&'a self) -> &'a S { self.parent.get_ref() } #[inline] - pub fn unwrap_parent(mut self) -> S { - use std::mem; + pub fn unwrap_parent(mut self) -> S { + use std::mem; mem::replace(&mut self.parent, None).unwrap() } @@ -498,7 +498,7 @@ impl Renderer { else { Err(get_error()) } } - pub fn fill_rect(&self, rect: &Rect) -> Result<(), String> { + pub fn fill_rect(&self, rect: &Rect) -> SdlResult<()> { let ret = unsafe { ll::SDL_RenderFillRect(self.raw, rect) }; if ret == 0 { Ok(()) } @@ -592,7 +592,7 @@ pub struct TextureQuery { pub height: int } -#[deriving(Eq)] #[allow(raw_pointer_deriving)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct Texture { pub raw: *ll::SDL_Texture, pub owned: bool @@ -733,7 +733,7 @@ impl Texture { if result { Ok((texw as f64, texh as f64)) } else { - Err("Operation not supported".into_owned()) + Err("Operation not supported".into_string()) } } diff --git a/src/sdl2/rwops.rs b/src/sdl2/rwops.rs index f6dc5021..61337e69 100644 --- a/src/sdl2/rwops.rs +++ b/src/sdl2/rwops.rs @@ -1,8 +1,6 @@ use std::io; use std::io::IoResult; -use get_error; use libc::{c_void, c_int, size_t}; - use get_error; use SdlResult; @@ -44,7 +42,7 @@ pub mod ll { } } -#[deriving(Eq)] #[allow(raw_pointer_deriving)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct RWops { raw: *ll::SDL_RWops, close_on_drop: bool diff --git a/src/sdl2/sdl.rs b/src/sdl2/sdl.rs index 6d8a0dfd..fc6704a0 100644 --- a/src/sdl2/sdl.rs +++ b/src/sdl2/sdl.rs @@ -74,7 +74,7 @@ bitflags!(flags InitFlag: u32 { static InitEverything = ll::SDL_INIT_EVERYTHING }) -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum Error { NoMemError = ll::SDL_ENOMEM as int, ReadError = ll::SDL_EFREAD as int, @@ -115,7 +115,7 @@ pub fn was_inited(flags: InitFlag) -> InitFlag { pub fn get_error() -> String { unsafe { let cstr = CString::new(ll::SDL_GetError(), false); - cstr.as_str().unwrap().into_owned() + cstr.as_str().unwrap().into_string() } } diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 93f0fbd7..a63bf55e 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -83,7 +83,7 @@ bitflags!(flags SurfaceFlag: u32 { static DontFree = ll::SDL_DONTFREE as u32 }) -#[deriving(Eq)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct Surface { raw: *ll::SDL_Surface, @@ -142,7 +142,7 @@ impl Surface { } pub fn get_pixel_format(&self) -> pixels::PixelFormat { - unsafe { + unsafe { pixels::PixelFormat::from_ll((*self.raw).format) } } @@ -190,12 +190,14 @@ impl Surface { } } + #[allow(non_snake_case_functions)] pub fn enable_RLE(&self) -> bool { unsafe { ll::SDL_SetSurfaceRLE(self.raw, 1) == 0 } } + #[allow(non_snake_case_functions)] pub fn disable_RLE(&self) -> bool { unsafe { ll::SDL_SetSurfaceRLE(self.raw, 0) == 0 diff --git a/src/sdl2/touch.rs b/src/sdl2/touch.rs index f6539c19..5d91d1e3 100644 --- a/src/sdl2/touch.rs +++ b/src/sdl2/touch.rs @@ -2,7 +2,7 @@ use std::ptr; pub type TouchDevice = ll::SDL_TouchID; -#[deriving(Eq)] +#[deriving(PartialEq)] pub struct Finger { id: TouchDevice, x: f32, diff --git a/src/sdl2/version.rs b/src/sdl2/version.rs index 48924d31..d83814d7 100644 --- a/src/sdl2/version.rs +++ b/src/sdl2/version.rs @@ -22,7 +22,7 @@ pub mod ll { } /// A structure that contains information about the version of SDL in use. -#[deriving(Eq, Clone)] +#[deriving(PartialEq, Clone)] pub struct Version { /// major version pub major: int, @@ -61,7 +61,7 @@ pub fn get_version() -> Version { pub fn get_revision() -> String { unsafe { let ret = ll::SDL_GetRevision(); - CString::new(ret, false).as_str().unwrap().into_owned() + CString::new(ret, false).as_str().unwrap().into_string() } } diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index d9600f4c..e636a606 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -182,7 +182,7 @@ pub mod ll { } } -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum GLAttr { GLRedSize = ll::SDL_GL_RED_SIZE as int, GLGreenSize = ll::SDL_GL_GREEN_SIZE as int, @@ -219,7 +219,7 @@ fn empty_sdl_display_mode() -> ll::SDL_DisplayMode { } } -#[deriving(Eq)] +#[deriving(PartialEq)] pub struct DisplayMode { pub format: u32, pub w: int, @@ -274,14 +274,14 @@ bitflags!(flags WindowFlags: u32 { static Foreign = ll::SDL_WINDOW_FOREIGN as u32 }) -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum FullscreenType { FTOff = 0, FTTrue = ll::SDL_WINDOW_FULLSCREEN as int, FTDesktop = ll::SDL_WINDOW_FULLSCREEN_DESKTOP as int } -#[deriving(Eq)] +#[deriving(PartialEq)] pub enum WindowPos { PosUndefined, PosCentered, @@ -296,7 +296,7 @@ fn unwrap_windowpos (pos: WindowPos) -> ll::SDL_WindowPos { } } -#[deriving(Eq)] +#[deriving(PartialEq)] pub struct GLContext { raw: ll::SDL_GLContext, owned: bool @@ -312,7 +312,7 @@ impl Drop for GLContext { } } -#[deriving(Eq)] +#[deriving(PartialEq)] #[allow(raw_pointer_deriving)] pub struct Window { raw: *ll::SDL_Window,