mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
fix warnings: deprecated to_owned, non_snake_case_functions
This commit is contained in:
@@ -49,7 +49,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
|
||||
},
|
||||
None => {
|
||||
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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
+5
-7
@@ -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;
|
||||
|
||||
+3
-3
@@ -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::<Vec<u8>>().as_slice()).into_owned();
|
||||
let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::<Vec<u8>>().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::<Vec<u8>>().as_slice()).into_owned();
|
||||
let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::<Vec<u8>>().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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -274,8 +274,8 @@ impl<S> Renderer<S> {
|
||||
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<S> Renderer<S> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user