From cedc85c55032afca28fe9b4a1bd11499267f6009 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 25 Mar 2015 19:57:38 +0100 Subject: Rustup --- src/win32/callback.rs | 8 ++++---- src/win32/init.rs | 2 +- src/win32/mod.rs | 1 - src/win32/monitor.rs | 10 ++++------ 4 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src/win32') diff --git a/src/win32/callback.rs b/src/win32/callback.rs index f9ec653..bbf5b55 100644 --- a/src/win32/callback.rs +++ b/src/win32/callback.rs @@ -1,6 +1,6 @@ use std::rc::Rc; use std::cell::RefCell; -use std::sync::mpsc::{Sender, Receiver, channel}; +use std::sync::mpsc::Sender; use Event; use super::event; @@ -52,7 +52,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT, }; if win == &window { - unsafe { user32::PostQuitMessage(0); } + user32::PostQuitMessage(0); } }); @@ -83,7 +83,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT, winapi::WM_CHAR => { use std::mem; use events::Event::ReceivedCharacter; - let chr: char = unsafe { mem::transmute(wparam as u32) }; + let chr: char = mem::transmute(wparam as u32); send_event(window, ReceivedCharacter(chr)); 0 }, @@ -188,7 +188,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT, 0 }, - _ => unsafe { + _ => { user32::DefWindowProcW(window, msg, wparam, lparam) } } diff --git a/src/win32/init.rs b/src/win32/init.rs index 8d2eb1e..5266ae4 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -235,7 +235,7 @@ unsafe fn init(title: Vec, builder: BuilderAttribs<'static>, // handling vsync if builder.vsync { if extra_functions.SwapIntervalEXT.is_loaded() { - let guard = try!(CurrentContextGuard::make_current(&real_window, &context)); + let _guard = try!(CurrentContextGuard::make_current(&real_window, &context)); if extra_functions.SwapIntervalEXT(1) == 0 { return Err(OsError(format!("wglSwapIntervalEXT failed"))); diff --git a/src/win32/mod.rs b/src/win32/mod.rs index 07f76e8..380342e 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -1,7 +1,6 @@ use std::sync::atomic::AtomicBool; use std::ptr; use std::ffi::CString; -use std::collections::VecDeque; use std::sync::mpsc::Receiver; use libc; use {CreationError, Event, MouseCursor}; diff --git a/src/win32/monitor.rs b/src/win32/monitor.rs index b5ffe2d..886d0bf 100644 --- a/src/win32/monitor.rs +++ b/src/win32/monitor.rs @@ -2,6 +2,7 @@ use winapi; use user32; use std::collections::VecDeque; +use std::mem; use native_monitor::NativeMonitorId; @@ -83,15 +84,12 @@ impl Iterator for DeviceEnumerator { fn wchar_as_string(wchar: &[winapi::WCHAR]) -> String { String::from_utf16_lossy(wchar) - .as_slice() .trim_right_matches(0 as char) .to_string() } /// Win32 implementation of the main `get_available_monitors` function. pub fn get_available_monitors() -> VecDeque { - use std::{iter, mem, ptr}; - // return value let mut result = VecDeque::new(); @@ -120,8 +118,8 @@ pub fn get_available_monitors() -> VecDeque { // adding to the resulting list result.push_back(MonitorID { adapter_name: adapter.DeviceName, - monitor_name: wchar_as_string(monitor.DeviceName.as_slice()), - readable_name: wchar_as_string(monitor.DeviceString.as_slice()), + monitor_name: wchar_as_string(&monitor.DeviceName), + readable_name: wchar_as_string(&monitor.DeviceString), flags: monitor.StateFlags, position: position, dimensions: dimensions, @@ -165,7 +163,7 @@ impl MonitorID { /// This is a Win32-only function for `MonitorID` that returns the system name of the adapter /// device. pub fn get_adapter_name(&self) -> &[winapi::WCHAR] { - self.adapter_name.as_slice() + &self.adapter_name } /// This is a Win32-only function for `MonitorID` that returns the position of the -- cgit v1.2.3