Fixed errors on latest nightly, RingBuf -> VecDeque

This commit is contained in:
mitchmindtree 2015-02-21 23:59:37 +11:00
parent 7ff76cddd9
commit 9bb41bf277
3 changed files with 12 additions and 12 deletions

View file

@ -24,7 +24,7 @@ use std::cell::Cell;
use std::ffi::{CString, c_str_to_bytes}; use std::ffi::{CString, c_str_to_bytes};
use std::mem; use std::mem;
use std::ptr; use std::ptr;
use std::collections::RingBuf; use std::collections::VecDeque;
use std::str::FromStr; use std::str::FromStr;
use std::str::from_utf8; use std::str::from_utf8;
use std::sync::Mutex; use std::sync::Mutex;
@ -48,7 +48,7 @@ static mut ctrl_pressed: bool = false;
static mut win_pressed: bool = false; static mut win_pressed: bool = false;
static mut alt_pressed: bool = false; static mut alt_pressed: bool = false;
struct DelegateState<'a> { struct DelegateState {
is_closed: bool, is_closed: bool,
context: id, context: id,
view: id, view: id,
@ -169,7 +169,7 @@ pub struct Window {
is_closed: Cell<bool>, is_closed: Cell<bool>,
/// Events that have been retreived with XLib but not dispatched with iterators yet /// Events that have been retreived with XLib but not dispatched with iterators yet
pending_events: Mutex<RingBuf<Event>>, pending_events: Mutex<VecDeque<Event>>,
} }
#[cfg(feature = "window")] #[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))) (scale_factor * (view_rect.size.height - view_point.y) as f32) as i32)))
}, },
NSKeyDown => { NSKeyDown => {
let mut events = RingBuf::new(); let mut events = VecDeque::new();
let received_c_str = event.characters().UTF8String(); let received_c_str = event.characters().UTF8String();
let received_str = CString::from_slice(c_str_to_bytes(&received_c_str)); 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() { 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)) Some(KeyboardInput(Released, NSEvent::keyCode(event) as u8, vkey))
}, },
NSFlagsChanged => { 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); let shift_modifier = Window::modifier_event(event, appkit::NSShiftKeyMask, events::VirtualKeyCode::LShift, shift_pressed);
if shift_modifier.is_some() { if shift_modifier.is_some() {
shift_pressed = !shift_pressed; shift_pressed = !shift_pressed;
@ -380,7 +380,7 @@ impl Window {
resize: None, resize: None,
is_closed: Cell::new(false), is_closed: Cell::new(false),
pending_events: Mutex::new(RingBuf::new()), pending_events: Mutex::new(VecDeque::new()),
}; };
Ok(window) Ok(window)

View file

@ -1,10 +1,10 @@
use core_graphics::display; use core_graphics::display;
use std::collections::RingBuf; use std::collections::VecDeque;
pub struct MonitorID(u32); pub struct MonitorID(u32);
pub fn get_available_monitors() -> RingBuf<MonitorID> { pub fn get_available_monitors() -> VecDeque<MonitorID> {
let mut monitors = RingBuf::new(); let mut monitors = VecDeque::new();
unsafe { unsafe {
let max_displays = 10u32; let max_displays = 10u32;
let mut active_displays = [0u32; 10]; let mut active_displays = [0u32; 10];
@ -12,7 +12,7 @@ pub fn get_available_monitors() -> RingBuf<MonitorID> {
display::CGGetActiveDisplayList(max_displays, display::CGGetActiveDisplayList(max_displays,
&mut active_displays[0], &mut active_displays[0],
&mut display_count); &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])); monitors.push_back(MonitorID(active_displays[i]));
} }
} }

View file

@ -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 std::default::Default;
use Api; 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. // Implementation note: we retreive the list once, then serve each element by one by one.
// This may change in the future. // This may change in the future.
pub struct AvailableMonitorsIter { pub struct AvailableMonitorsIter {
data: RingBufIter<winimpl::MonitorID>, data: VecDequeIter<winimpl::MonitorID>,
} }
impl Iterator for AvailableMonitorsIter { impl Iterator for AvailableMonitorsIter {