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..82d6b5e1 100644 --- a/src/codegen/keycode.rs +++ b/src/codegen/keycode.rs @@ -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 { @@ -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..82921c42 100644 --- a/src/codegen/scancode.rs +++ b/src/codegen/scancode.rs @@ -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 { @@ -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..09d82f43 100644 --- a/src/sdl2/audio.rs +++ b/src/sdl2/audio.rs @@ -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, @@ -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/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/render.rs b/src/sdl2/render.rs index 08a03988..ff2b9b05 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -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(()) } @@ -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..ec0909c8 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; diff --git a/src/sdl2/sdl.rs b/src/sdl2/sdl.rs index 6d8a0dfd..a0c7722c 100644 --- a/src/sdl2/sdl.rs +++ b/src/sdl2/sdl.rs @@ -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..8d622730 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -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/version.rs b/src/sdl2/version.rs index 48924d31..24ca2217 100644 --- a/src/sdl2/version.rs +++ b/src/sdl2/version.rs @@ -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() } }