From 6abfac083feafc73e5d736177755cce3bfb7153f Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Tue, 30 Dec 2014 10:51:18 -0800 Subject: Fallout from stabilization --- src/libstd/sys/unix/timer.rs | 10 +++++----- src/libstd/sys/windows/os.rs | 3 ++- src/libstd/sys/windows/tty.rs | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index fe393b81e3d..c0ef89666c0 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -120,9 +120,9 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { // signals the first requests in the queue, possible re-enqueueing it. fn signal(active: &mut Vec>, dead: &mut Vec<(uint, Box)>) { - let mut timer = match active.remove(0) { - Some(timer) => timer, None => return - }; + if active.is_empty() { return } + + let mut timer = active.remove(0); let mut cb = timer.cb.take().unwrap(); cb.call(); if timer.repeat { @@ -178,7 +178,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { Ok(RemoveTimer(id, ack)) => { match dead.iter().position(|&(i, _)| id == i) { Some(i) => { - let (_, i) = dead.remove(i).unwrap(); + let (_, i) = dead.remove(i); ack.send(i); continue } @@ -186,7 +186,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { } let i = active.iter().position(|i| i.id == id); let i = i.expect("no timer found"); - let t = active.remove(i).unwrap(); + let t = active.remove(i); ack.send(t); } Err(..) => break diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index fa08290a888..210feb9aee7 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -17,6 +17,7 @@ use prelude::*; use fmt; use io::{IoResult, IoError}; +use iter::repeat; use libc::{c_int, c_char, c_void}; use libc; use os; @@ -130,7 +131,7 @@ pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD) -> Option = repeat(0u16).take(n).collect(); let k = f(buf.as_mut_ptr(), n); if k == (0 as DWORD) { done = true; diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index 99292b3b44b..a88d11eed22 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -34,6 +34,7 @@ use libc::{c_int, HANDLE, LPDWORD, DWORD, LPVOID}; use libc::{get_osfhandle, CloseHandle}; use libc::types::os::arch::extra::LPCVOID; use io::{mod, IoError, IoResult, MemReader}; +use iter::repeat; use prelude::*; use ptr; use str::from_utf8; @@ -89,7 +90,7 @@ impl TTY { pub fn read(&mut self, buf: &mut [u8]) -> IoResult { // Read more if the buffer is empty if self.utf8.eof() { - let mut utf16 = Vec::from_elem(0x1000, 0u16); + let mut utf16: Vec = repeat(0u16).take(0x1000).collect(); let mut num: DWORD = 0; match unsafe { ReadConsoleW(self.handle, utf16.as_mut_ptr() as LPVOID, -- cgit 1.4.1-3-g733a5