about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-30 18:51:51 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-12-30 18:51:51 -0800
commit67d13883f868e6b27aa00a6c69f7c748d16e1c94 (patch)
tree195395a9e6d556c7c60a1507376a75e9e0c348bb /src/libstd/sys
parentdd0f29ad0f3ddc48f36340cd0abff4712e882a3e (diff)
parent6abfac083feafc73e5d736177755cce3bfb7153f (diff)
downloadrust-67d13883f868e6b27aa00a6c69f7c748d16e1c94.tar.gz
rust-67d13883f868e6b27aa00a6c69f7c748d16e1c94.zip
rollup merge of #20061: aturon/stab-2-vec-slice
Conflicts:
	src/libcollections/slice.rs
	src/libcollections/vec.rs
	src/libstd/sys/windows/os.rs
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/timer.rs10
-rw-r--r--src/libstd/sys/windows/os.rs5
-rw-r--r--src/libstd/sys/windows/tty.rs3
3 files changed, 10 insertions, 8 deletions
diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs
index 1ababbc0d85..150ec6aad8a 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 {
@@ -185,7 +185,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
                                 }
@@ -193,7 +193,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 5a7be63e39f..235ebf211ac 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -16,13 +16,14 @@
 use prelude::*;
 
 use io::{IoResult, IoError};
+use iter::repeat;
 use libc::{c_int, c_void};
 use libc;
 use os;
 use path::BytesContainer;
 use ptr;
-use sys::fs::FileDesc;
 use slice;
+use sys::fs::FileDesc;
 
 use os::TMPBUF_SZ;
 use libc::types::os::arch::extra::DWORD;
@@ -128,7 +129,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 607bb05f54f..415524733ff 100644
--- a/src/libstd/sys/windows/tty.rs
+++ b/src/libstd/sys/windows/tty.rs
@@ -33,6 +33,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;
@@ -90,7 +91,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,