diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-30 18:51:51 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-30 18:51:51 -0800 |
| commit | 67d13883f868e6b27aa00a6c69f7c748d16e1c94 (patch) | |
| tree | 195395a9e6d556c7c60a1507376a75e9e0c348bb /src/libstd | |
| parent | dd0f29ad0f3ddc48f36340cd0abff4712e882a3e (diff) | |
| parent | 6abfac083feafc73e5d736177755cce3bfb7153f (diff) | |
| download | rust-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')
| -rw-r--r-- | src/libstd/c_str.rs | 2 | ||||
| -rw-r--r-- | src/libstd/comm/sync.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/buffered.rs | 7 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 | ||||
| -rw-r--r-- | src/libstd/os.rs | 9 | ||||
| -rw-r--r-- | src/libstd/path/posix.rs | 6 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 4 | ||||
| -rw-r--r-- | src/libstd/prelude.rs | 7 | ||||
| -rw-r--r-- | src/libstd/rt/args.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/timer.rs | 10 | ||||
| -rw-r--r-- | src/libstd/sys/windows/os.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/windows/tty.rs | 3 |
12 files changed, 32 insertions, 28 deletions
diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index 8dbaab564ba..4e22fc60080 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -74,7 +74,7 @@ use fmt; use hash; use mem; use ptr; -use slice::{mod, ImmutableIntSlice}; +use slice::{mod, IntSliceExt}; use str; use string::String; use core::kinds::marker; diff --git a/src/libstd/comm/sync.rs b/src/libstd/comm/sync.rs index 82ec1814ebd..a8004155af0 100644 --- a/src/libstd/comm/sync.rs +++ b/src/libstd/comm/sync.rs @@ -148,7 +148,7 @@ impl<T: Send> Packet<T> { tail: 0 as *mut Node, }, buf: Buffer { - buf: Vec::from_fn(cap + if cap == 0 {1} else {0}, |_| None), + buf: range(0, cap + if cap == 0 {1} else {0}).map(|_| None).collect(), start: 0, size: 0, }, diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index fdbce101c1d..0fba0f6704b 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -439,9 +439,10 @@ mod test { impl Reader for ShortReader { fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> { - match self.lengths.remove(0) { - Some(i) => Ok(i), - None => Err(io::standard_error(io::EndOfFile)) + if self.lengths.is_empty() { + Err(io::standard_error(io::EndOfFile)) + } else { + Ok(self.lengths.remove(0)) } } } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 5c70340fe10..181c4c04c51 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -158,6 +158,7 @@ pub use alloc::rc; pub use core_collections::slice; pub use core_collections::str; pub use core_collections::string; +#[stable] pub use core_collections::vec; pub use unicode::char; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 989f44f7b8e..a9d9607395c 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -620,10 +620,11 @@ pub fn get_exit_status() -> int { unsafe fn load_argc_and_argv(argc: int, argv: *const *const c_char) -> Vec<Vec<u8>> { use c_str::CString; + use iter::range; - Vec::from_fn(argc as uint, |i| { + range(0, argc as uint).map(|i| { CString::new(*argv.offset(i as int), false).as_bytes_no_nul().to_vec() - }) + }).collect() } /// Returns the command line arguments @@ -721,7 +722,7 @@ fn real_args() -> Vec<String> { let lpCmdLine = unsafe { GetCommandLineW() }; let szArgList = unsafe { CommandLineToArgvW(lpCmdLine, lpArgCount) }; - let args = Vec::from_fn(nArgs as uint, |i| unsafe { + let args: Vec<_> = range(0, nArgs as uint).map(|i| unsafe { // Determine the length of this argument. let ptr = *szArgList.offset(i as int); let mut len = 0; @@ -732,7 +733,7 @@ fn real_args() -> Vec<String> { let buf = slice::from_raw_buf(&ptr, len); let opt_s = String::from_utf16(sys::os::truncate_utf16_at_nul(buf)); opt_s.ok().expect("CommandLineToArgvW returned invalid UTF-16") - }); + }).collect(); unsafe { LocalFree(szArgList as *mut c_void); diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 60f147eac9b..bd4031e6230 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -22,14 +22,14 @@ use option::Option::{None, Some}; use kinds::Sized; use str::{FromStr, Str}; use str; -use slice::{CloneSliceExt, Splits, AsSlice, VectorVector, +use slice::{CloneSliceExt, Split, AsSlice, SliceConcatExt, PartialEqSliceExt, SliceExt}; use vec::Vec; use super::{BytesContainer, GenericPath, GenericPathUnsafe}; /// Iterator that yields successive components of a Path as &[u8] -pub type Components<'a> = Splits<'a, u8, fn(&u8) -> bool>; +pub type Components<'a> = Split<'a, u8, fn(&u8) -> bool>; /// Iterator that yields successive components of a Path as Option<&str> pub type StrComponents<'a> = @@ -306,7 +306,7 @@ impl GenericPath for Path { } } } - Some(Path::new(comps.connect_vec(&SEP_BYTE))) + Some(Path::new(comps.as_slice().connect(&SEP_BYTE))) } } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 879a96e8026..751ed4b70fb 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -25,8 +25,8 @@ use iter::{Iterator, IteratorExt, Map, repeat}; use mem; use option::Option; use option::Option::{Some, None}; -use slice::SliceExt; -use str::{SplitTerminator, FromStr, StrVector, StrExt}; +use slice::{SliceExt, SliceConcatExt}; +use str::{SplitTerminator, FromStr, StrExt}; use string::{String, ToString}; use unicode::char::UnicodeChar; use vec::Vec; diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index fc59f06ae6c..f016683e3d0 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -66,7 +66,7 @@ #[doc(no_inline)] pub use iter::{FromIterator, Extend, ExactSizeIterator}; #[doc(no_inline)] pub use iter::{Iterator, IteratorExt, DoubleEndedIterator}; #[doc(no_inline)] pub use iter::{DoubleEndedIteratorExt, CloneIteratorExt}; -#[doc(no_inline)] pub use iter::{RandomAccessIterator, IteratorCloneExt}; +#[doc(no_inline)] pub use iter::{RandomAccessIterator, IteratorCloneExt, IteratorPairExt}; #[doc(no_inline)] pub use iter::{IteratorOrdExt, MutableDoubleEndedIterator}; #[doc(no_inline)] pub use num::{ToPrimitive, FromPrimitive}; #[doc(no_inline)] pub use boxed::Box; @@ -80,10 +80,9 @@ #[doc(no_inline)] pub use core::prelude::{Tuple1, Tuple2, Tuple3, Tuple4}; #[doc(no_inline)] pub use core::prelude::{Tuple5, Tuple6, Tuple7, Tuple8}; #[doc(no_inline)] pub use core::prelude::{Tuple9, Tuple10, Tuple11, Tuple12}; -#[doc(no_inline)] pub use str::{Str, StrVector}; -#[doc(no_inline)] pub use str::StrExt; +#[doc(no_inline)] pub use str::{Str, StrExt}; #[doc(no_inline)] pub use slice::AsSlice; -#[doc(no_inline)] pub use slice::{VectorVector, PartialEqSliceExt}; +#[doc(no_inline)] pub use slice::{SliceConcatExt, PartialEqSliceExt}; #[doc(no_inline)] pub use slice::{CloneSliceExt, OrdSliceExt, SliceExt}; #[doc(no_inline)] pub use slice::{BoxedSliceExt}; #[doc(no_inline)] pub use string::{IntoString, String, ToString}; diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index b1f268597c7..98eff621ce0 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -95,14 +95,14 @@ mod imp { } unsafe fn load_argc_and_argv(argc: int, argv: *const *const u8) -> Vec<Vec<u8>> { - Vec::from_fn(argc as uint, |i| { + range(0, argc as uint).map(|i| { let arg = *argv.offset(i as int); let mut len = 0u; while *arg.offset(len as int) != 0 { len += 1u; } slice::from_raw_buf(&arg, len).to_vec() - }) + }).collect() } #[cfg(test)] 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, |
