about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-12-30 10:51:18 -0800
committerAaron Turon <aturon@mozilla.com>2014-12-30 17:06:08 -0800
commit6abfac083feafc73e5d736177755cce3bfb7153f (patch)
treed5502fab0dd68ea96057616eb20d90a2c9050218 /src/libstd/sys
parent6e1879eaf1cb5e727eb134a3e27018f7535852eb (diff)
downloadrust-6abfac083feafc73e5d736177755cce3bfb7153f.tar.gz
rust-6abfac083feafc73e5d736177755cce3bfb7153f.zip
Fallout from stabilization
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/timer.rs10
-rw-r--r--src/libstd/sys/windows/os.rs3
-rw-r--r--src/libstd/sys/windows/tty.rs3
3 files changed, 9 insertions, 7 deletions
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<Req>, _: ()) {
     // signals the first requests in the queue, possible re-enqueueing it.
     fn signal(active: &mut Vec<Box<Inner>>,
               dead: &mut Vec<(uint, Box<Inner>)>) {
-        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<Req>, _: ()) {
                         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<Req>, _: ()) {
                             }
                             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<String
         let mut res = None;
         let mut done = false;
         while !done {
-            let mut buf = Vec::from_elem(n as uint, 0u16);
+            let mut buf: Vec<u16> = 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<uint> {
         // Read more if the buffer is empty
         if self.utf8.eof() {
-            let mut utf16 = Vec::from_elem(0x1000, 0u16);
+            let mut utf16: Vec<u16> = repeat(0u16).take(0x1000).collect();
             let mut num: DWORD = 0;
             match unsafe { ReadConsoleW(self.handle,
                                          utf16.as_mut_ptr() as LPVOID,