From accf2f3cc3b0ac11881ec8f1e225e28a8e07055d Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 21 Feb 2015 18:07:35 -0500 Subject: [PATCH 1/4] Deref before matching rust-guidelines encourages this --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3798ffdd..54f4b168 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,9 +84,9 @@ pub enum CreationError { impl CreationError { fn to_string(&self) -> &str { - match self { - &CreationError::OsError(ref text) => text.as_slice(), - &CreationError::NotSupported => "Some of the requested attributes are not supported", + match *self { + CreationError::OsError(ref text) => text.as_slice(), + CreationError::NotSupported => "Some of the requested attributes are not supported", } } } From f4c9bd81bbebb0081271d5ebc763fc1aba9dad0a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 21 Feb 2015 18:12:32 -0500 Subject: [PATCH 2/4] Opt into features to silence warnings --- build.rs | 1 + src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index a151502a..b2813e03 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,5 @@ #![allow(unstable)] +#![feature(old_io,old_path,os)] extern crate gl_generator; extern crate khronos_api; diff --git a/src/lib.rs b/src/lib.rs index 54f4b168..e7d7b68f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(unsafe_destructor)] +#![feature(unsafe_destructor,core,std_misc)] #![unstable] #![allow(unstable)] From 7fa19ab0dfd0624386ae1086ad1d740072d7f1a4 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 21 Feb 2015 18:19:03 -0500 Subject: [PATCH 3/4] Remove deprecated 'allow' lint --- build.rs | 1 - src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/build.rs b/build.rs index b2813e03..6088615e 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,3 @@ -#![allow(unstable)] #![feature(old_io,old_path,os)] extern crate gl_generator; extern crate khronos_api; diff --git a/src/lib.rs b/src/lib.rs index e7d7b68f..4ab577a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #![feature(unsafe_destructor,core,std_misc)] #![unstable] -#![allow(unstable)] //! The purpose of this library is to provide an OpenGL context on as many //! platforms as possible. From 5ff649e5db99cd2ad4c8b22f5894b4283c35b6ea Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 21 Feb 2015 18:32:05 -0500 Subject: [PATCH 4/4] Stop using deprecated CString::from_slice constructor --- src/cocoa/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cocoa/mod.rs b/src/cocoa/mod.rs index 12f7a06f..7690459a 100644 --- a/src/cocoa/mod.rs +++ b/src/cocoa/mod.rs @@ -21,7 +21,7 @@ use core_foundation::string::CFString; use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName}; use std::cell::Cell; -use std::ffi::{CString, c_str_to_bytes}; +use std::ffi::{CString, CStr}; use std::mem; use std::ptr; use std::collections::VecDeque; @@ -115,15 +115,15 @@ impl WindowDelegate { class_addMethod(delegate_class, selector("windowShouldClose:"), window_should_close, - CString::from_slice("B@:@".as_bytes()).as_ptr()); + CString::new("B@:@").unwrap().as_ptr()); class_addMethod(delegate_class, selector("windowDidResize:"), window_did_resize, - CString::from_slice("V@:@".as_bytes()).as_ptr()); + CString::new("V@:@").unwrap().as_ptr()); // Store internal state as user data class_addIvar(delegate_class, WindowDelegate::state_ivar_name().as_ptr() as *const i8, ptr_size as u64, 3, - CString::from_slice("?".as_bytes()).as_ptr()); + CString::new("?").unwrap().as_ptr()); objc_registerClassPair(delegate_class); // Free class at exit rt::at_exit(|| { @@ -254,8 +254,8 @@ impl<'a> Iterator for PollEventsIterator<'a> { NSKeyDown => { let mut events = VecDeque::new(); let received_c_str = event.characters().UTF8String(); - let received_str = CString::from_slice(c_str_to_bytes(&received_c_str)); - for received_char in from_utf8(received_str.as_bytes()).unwrap().chars() { + let received_str = CStr::from_ptr(received_c_str); + for received_char in from_utf8(received_str.to_bytes()).unwrap().chars() { if received_char.is_ascii() { events.push_back(ReceivedCharacter(received_char)); }