diff --git a/src/android/mod.rs b/src/android/mod.rs index 30e6c087..bcf08ad4 100644 --- a/src/android/mod.rs +++ b/src/android/mod.rs @@ -9,7 +9,7 @@ use events::ElementState::{Pressed, Released}; use events::Event::{MouseInput, MouseMoved}; use events::MouseButton; -use std::collections::RingBuf; +use std::collections::VecDeque; use Api; use BuilderAttribs; @@ -26,8 +26,8 @@ pub struct MonitorID; mod ffi; -pub fn get_available_monitors() -> RingBuf { - let mut rb = RingBuf::new(); +pub fn get_available_monitors() -> VecDeque { + let mut rb = VecDeque::new(); rb.push_back(MonitorID); rb } @@ -313,7 +313,7 @@ impl Window { pub fn get_proc_address(&self, addr: &str) -> *const () { let addr = CString::from_slice(addr.as_bytes()); - let addr = addr.as_slice_with_nul().as_ptr(); + let addr = addr.as_ptr(); unsafe { ffi::egl::GetProcAddress(addr) as *const () } diff --git a/src/cocoa/mod.rs b/src/cocoa/mod.rs index 5d7bcd97..12f7a06f 100644 --- a/src/cocoa/mod.rs +++ b/src/cocoa/mod.rs @@ -24,7 +24,7 @@ use std::cell::Cell; use std::ffi::{CString, c_str_to_bytes}; use std::mem; use std::ptr; -use std::collections::RingBuf; +use std::collections::VecDeque; use std::str::FromStr; use std::str::from_utf8; use std::sync::Mutex; @@ -48,7 +48,7 @@ static mut ctrl_pressed: bool = false; static mut win_pressed: bool = false; static mut alt_pressed: bool = false; -struct DelegateState<'a> { +struct DelegateState { is_closed: bool, context: id, view: id, @@ -169,7 +169,7 @@ pub struct Window { is_closed: Cell, /// Events that have been retreived with XLib but not dispatched with iterators yet - pending_events: Mutex>, + pending_events: Mutex>, } #[cfg(feature = "window")] @@ -252,7 +252,7 @@ impl<'a> Iterator for PollEventsIterator<'a> { (scale_factor * (view_rect.size.height - view_point.y) as f32) as i32))) }, NSKeyDown => { - let mut events = RingBuf::new(); + 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() { @@ -272,7 +272,7 @@ impl<'a> Iterator for PollEventsIterator<'a> { Some(KeyboardInput(Released, NSEvent::keyCode(event) as u8, vkey)) }, NSFlagsChanged => { - let mut events = RingBuf::new(); + let mut events = VecDeque::new(); let shift_modifier = Window::modifier_event(event, appkit::NSShiftKeyMask, events::VirtualKeyCode::LShift, shift_pressed); if shift_modifier.is_some() { shift_pressed = !shift_pressed; @@ -380,7 +380,7 @@ impl Window { resize: None, is_closed: Cell::new(false), - pending_events: Mutex::new(RingBuf::new()), + pending_events: Mutex::new(VecDeque::new()), }; Ok(window) diff --git a/src/cocoa/monitor.rs b/src/cocoa/monitor.rs index 912c02d1..47adc031 100644 --- a/src/cocoa/monitor.rs +++ b/src/cocoa/monitor.rs @@ -1,10 +1,10 @@ use core_graphics::display; -use std::collections::RingBuf; +use std::collections::VecDeque; pub struct MonitorID(u32); -pub fn get_available_monitors() -> RingBuf { - let mut monitors = RingBuf::new(); +pub fn get_available_monitors() -> VecDeque { + let mut monitors = VecDeque::new(); unsafe { let max_displays = 10u32; let mut active_displays = [0u32; 10]; @@ -12,7 +12,7 @@ pub fn get_available_monitors() -> RingBuf { display::CGGetActiveDisplayList(max_displays, &mut active_displays[0], &mut display_count); - for i in range(0us, display_count as usize) { + for i in range(0, display_count as usize) { monitors.push_back(MonitorID(active_displays[i])); } } diff --git a/src/win32/init.rs b/src/win32/init.rs index 246a6b79..53fbc96e 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -171,7 +171,7 @@ fn init(title: Vec, builder: BuilderAttribs<'static>, builder_sharelists: O use libc; let addr = CString::from_slice(addr.as_bytes()); - let addr = addr.as_slice_with_nul().as_ptr(); + let addr = addr.as_ptr(); unsafe { gl::wgl::GetProcAddress(addr) as *const libc::c_void diff --git a/src/win32/mod.rs b/src/win32/mod.rs index cfb573a4..4846d59f 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -1,7 +1,7 @@ use std::sync::atomic::AtomicBool; use std::ptr; use std::ffi::CString; -use std::collections::RingBuf; +use std::collections::VecDeque; use std::sync::mpsc::Receiver; use libc; use {CreationError, Event, MouseCursor}; @@ -192,7 +192,7 @@ impl Window { /// See the docs in the crate root file. pub fn get_proc_address(&self, addr: &str) -> *const () { let addr = CString::from_slice(addr.as_bytes()); - let addr = addr.as_slice_with_nul().as_ptr(); + let addr = addr.as_ptr(); unsafe { let p = gl::wgl::GetProcAddress(addr) as *const (); diff --git a/src/win32/monitor.rs b/src/win32/monitor.rs index bcf27e2e..fc9f20d0 100644 --- a/src/win32/monitor.rs +++ b/src/win32/monitor.rs @@ -1,7 +1,7 @@ use winapi; use user32; -use std::collections::RingBuf; +use std::collections::VecDeque; /// Win32 implementation of the main `MonitorID` object. pub struct MonitorID { @@ -25,11 +25,11 @@ pub struct MonitorID { } /// Win32 implementation of the main `get_available_monitors` function. -pub fn get_available_monitors() -> RingBuf { +pub fn get_available_monitors() -> VecDeque { use std::{iter, mem, ptr}; // return value - let mut result = RingBuf::new(); + let mut result = VecDeque::new(); // enumerating the devices is done by querying device 0, then device 1, then device 2, etc. // until the query function returns null diff --git a/src/window.rs b/src/window.rs index 56f3410c..f82fa4f9 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,4 +1,4 @@ -use std::collections::ring_buf::IntoIter as RingBufIter; +use std::collections::vec_deque::IntoIter as VecDequeIter; use std::default::Default; use Api; @@ -452,7 +452,7 @@ impl<'a> Iterator for WaitEventsIterator<'a> { // Implementation note: we retreive the list once, then serve each element by one by one. // This may change in the future. pub struct AvailableMonitorsIter { - data: RingBufIter, + data: VecDequeIter, } impl Iterator for AvailableMonitorsIter { diff --git a/src/x11/headless.rs b/src/x11/headless.rs index 20d86e3a..ca47414a 100644 --- a/src/x11/headless.rs +++ b/src/x11/headless.rs @@ -8,7 +8,7 @@ use super::ffi; fn with_c_str(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T { use std::ffi::CString; let c_str = CString::from_slice(s.as_bytes()); - f(c_str.as_slice_with_nul().as_ptr()) + f(c_str.as_ptr()) } pub struct HeadlessContext { diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index faeea3e8..8664b4a7 100644 --- a/src/x11/window/mod.rs +++ b/src/x11/window/mod.rs @@ -5,7 +5,7 @@ use libc; use std::{mem, ptr}; use std::cell::Cell; use std::sync::atomic::AtomicBool; -use std::collections::RingBuf; +use std::collections::VecDeque; use super::ffi; use std::sync::{Arc, Mutex, Once, ONCE_INIT, Weak}; use std::sync::{StaticMutex, MUTEX_INIT}; @@ -39,7 +39,7 @@ fn ensure_thread_init() { fn with_c_str(s: &str, f: F) -> T where F: FnOnce(*const libc::c_char) -> T { use std::ffi::CString; let c_str = CString::from_slice(s.as_bytes()); - f(c_str.as_slice_with_nul().as_ptr()) + f(c_str.as_ptr()) } struct XWindow { @@ -281,7 +281,7 @@ pub struct Window { wm_delete_window: ffi::Atom, current_size: Cell<(libc::c_int, libc::c_int)>, /// Events that have been retreived with XLib but not dispatched with iterators yet - pending_events: Mutex>, + pending_events: Mutex>, } impl Window { @@ -600,7 +600,7 @@ impl Window { is_closed: AtomicBool::new(false), wm_delete_window: wm_delete_window, current_size: Cell::new((0, 0)), - pending_events: Mutex::new(RingBuf::new()), + pending_events: Mutex::new(VecDeque::new()), }; // returning diff --git a/src/x11/window/monitor.rs b/src/x11/window/monitor.rs index 3c188b6d..77ac4ec1 100644 --- a/src/x11/window/monitor.rs +++ b/src/x11/window/monitor.rs @@ -1,11 +1,11 @@ use std::ptr; -use std::collections::RingBuf; +use std::collections::VecDeque; use super::super::ffi; use super::ensure_thread_init; pub struct MonitorID(pub u32); -pub fn get_available_monitors() -> RingBuf { +pub fn get_available_monitors() -> VecDeque { ensure_thread_init(); let nb_monitors = unsafe { let display = ffi::XOpenDisplay(ptr::null()); @@ -17,7 +17,7 @@ pub fn get_available_monitors() -> RingBuf { nb_monitors }; - let mut monitors = RingBuf::new(); + let mut monitors = VecDeque::new(); monitors.extend(range(0, nb_monitors).map(|i| MonitorID(i as u32))); monitors }