about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-09-17 12:56:31 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-09-21 22:15:51 -0700
commit0169218047dc989acf9ea25e3122b9c659acb6b3 (patch)
tree8b1cd720a9e38c745359581e74d216a04e39e5ef /src/libstd
parent087b9283a0ed8df68f47ab07a25e60bc6a3ca050 (diff)
downloadrust-0169218047dc989acf9ea25e3122b9c659acb6b3.tar.gz
rust-0169218047dc989acf9ea25e3122b9c659acb6b3.zip
Fix fallout from Vec stabilization
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/dynamic_lib.rs5
-rw-r--r--src/libstd/io/comm_adapters.rs4
-rw-r--r--src/libstd/io/fs.rs4
-rw-r--r--src/libstd/os.rs50
-rw-r--r--src/libstd/path/mod.rs6
-rw-r--r--src/libstd/path/posix.rs2
-rw-r--r--src/libstd/path/windows.rs12
7 files changed, 45 insertions, 38 deletions
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs
index 32e461b55b1..e8d570f30e6 100644
--- a/src/libstd/dynamic_lib.rs
+++ b/src/libstd/dynamic_lib.rs
@@ -281,6 +281,7 @@ pub mod dl {
 #[cfg(target_os = "windows")]
 pub mod dl {
     use c_str::ToCStr;
+    use collections::MutableSeq;
     use iter::Iterator;
     use libc;
     use os;
@@ -295,8 +296,8 @@ pub mod dl {
         // Windows expects Unicode data
         let filename_cstr = filename.to_c_str();
         let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap();
-        let filename_str: Vec<u16> = filename_str.utf16_units().collect();
-        let filename_str = filename_str.append_one(0);
+        let mut filename_str: Vec<u16> = filename_str.utf16_units().collect();
+        filename_str.push(0);
         LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) as *mut u8
     }
 
diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs
index f2ff5c7b5c2..0a969fc37c9 100644
--- a/src/libstd/io/comm_adapters.rs
+++ b/src/libstd/io/comm_adapters.rs
@@ -15,7 +15,7 @@ use comm::{Sender, Receiver};
 use io;
 use option::{None, Option, Some};
 use result::{Ok, Err};
-use slice::{bytes, MutableSlice, ImmutableSlice};
+use slice::{bytes, MutableSlice, ImmutableSlice, CloneableVector};
 use str::StrSlice;
 use super::{Reader, Writer, IoResult};
 use vec::Vec;
@@ -118,7 +118,7 @@ impl Clone for ChanWriter {
 
 impl Writer for ChanWriter {
     fn write(&mut self, buf: &[u8]) -> IoResult<()> {
-        self.tx.send_opt(Vec::from_slice(buf)).map_err(|_| {
+        self.tx.send_opt(buf.to_vec()).map_err(|_| {
             io::IoError {
                 kind: io::BrokenPipe,
                 desc: "Pipe closed",
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs
index f912b3ee38f..b8e18fc44cb 100644
--- a/src/libstd/io/fs.rs
+++ b/src/libstd/io/fs.rs
@@ -61,7 +61,7 @@ use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader};
 use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
 use io::UpdateIoError;
 use io;
-use iter::Iterator;
+use iter::{Iterator, Extendable};
 use kinds::Send;
 use libc;
 use option::{Some, None, Option};
@@ -688,7 +688,7 @@ impl Iterator<Path> for Directories {
                                                 e, path.display()));
 
                     match result {
-                        Ok(dirs) => { self.stack.push_all_move(dirs); }
+                        Ok(dirs) => { self.stack.extend(dirs.into_iter()); }
                         Err(..) => {}
                     }
                 }
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 594a1cd131a..81dd114ec7d 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -46,15 +46,14 @@ use ptr::RawPtr;
 use ptr;
 use result::{Err, Ok, Result};
 use slice::{Slice, ImmutableSlice, MutableSlice, ImmutablePartialEqSlice};
+use slice::CloneableVector;
 use str::{Str, StrSlice, StrAllocating};
 use string::String;
 use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
 use vec::Vec;
 
-#[cfg(unix)]
-use c_str::ToCStr;
-#[cfg(unix)]
-use libc::c_char;
+#[cfg(unix)] use c_str::ToCStr;
+#[cfg(unix)] use libc::c_char;
 
 /// Get the number of cores available
 pub fn num_cpus() -> uint {
@@ -260,8 +259,11 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
             let mut i = 0;
             while *ch.offset(i) != 0 {
                 let p = &*ch.offset(i);
-                let len = ptr::position(p, |c| *c == 0);
-                raw::buf_as_slice(p, len, |s| {
+                let mut len = 0;
+                while *(p as *const _).offset(len) != 0 {
+                    len += 1;
+                }
+                raw::buf_as_slice(p, len as uint, |s| {
                     result.push(String::from_utf16_lossy(s).into_bytes());
                 });
                 i += len as int + 1;
@@ -284,7 +286,7 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
             let mut result = Vec::new();
             while *environ != 0 as *const _ {
                 let env_pair =
-                    Vec::from_slice(CString::new(*environ, false).as_bytes_no_nul());
+                    CString::new(*environ, false).as_bytes_no_nul().to_vec();
                 result.push(env_pair);
                 environ = environ.offset(1);
             }
@@ -295,9 +297,9 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
             let mut pairs = Vec::new();
             for p in input.iter() {
                 let mut it = p.as_slice().splitn(1, |b| *b == b'=');
-                let key = Vec::from_slice(it.next().unwrap());
+                let key = it.next().unwrap().to_vec();
                 let default: &[u8] = &[];
-                let val = Vec::from_slice(it.next().unwrap_or(default));
+                let val = it.next().unwrap_or(default).to_vec();
                 pairs.push((key, val));
             }
             pairs
@@ -351,8 +353,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
             if s.is_null() {
                 None
             } else {
-                Some(Vec::from_slice(CString::new(s as *const i8,
-                                                  false).as_bytes_no_nul()))
+                Some(CString::new(s as *const i8, false).as_bytes_no_nul().to_vec())
             }
         })
     }
@@ -365,8 +366,8 @@ pub fn getenv(n: &str) -> Option<String> {
     unsafe {
         with_env_lock(|| {
             use os::windows::{fill_utf16_buf_and_decode};
-            let n: Vec<u16> = n.utf16_units().collect();
-            let n = n.append_one(0);
+            let mut n: Vec<u16> = n.utf16_units().collect();
+            n.push(0);
             fill_utf16_buf_and_decode(|buf, sz| {
                 libc::GetEnvironmentVariableW(n.as_ptr(), buf, sz)
             })
@@ -412,10 +413,10 @@ pub fn setenv<T: BytesContainer>(n: &str, v: T) {
 
     #[cfg(windows)]
     fn _setenv(n: &str, v: &[u8]) {
-        let n: Vec<u16> = n.utf16_units().collect();
-        let n = n.append_one(0);
-        let v: Vec<u16> = ::str::from_utf8(v).unwrap().utf16_units().collect();
-        let v = v.append_one(0);
+        let mut n: Vec<u16> = n.utf16_units().collect();
+        n.push(0);
+        let mut v: Vec<u16> = ::str::from_utf8(v).unwrap().utf16_units().collect();
+        v.push(0);
 
         unsafe {
             with_env_lock(|| {
@@ -442,8 +443,8 @@ pub fn unsetenv(n: &str) {
 
     #[cfg(windows)]
     fn _unsetenv(n: &str) {
-        let n: Vec<u16> = n.utf16_units().collect();
-        let n = n.append_one(0);
+        let mut n: Vec<u16> = n.utf16_units().collect();
+        n.push(0);
         unsafe {
             with_env_lock(|| {
                 libc::SetEnvironmentVariableW(n.as_ptr(), ptr::null());
@@ -883,7 +884,11 @@ pub fn change_dir(p: &Path) -> bool {
     #[cfg(windows)]
     fn chdir(p: &Path) -> bool {
         let p = match p.as_str() {
-            Some(s) => s.utf16_units().collect::<Vec<u16>>().append_one(0),
+            Some(s) => {
+                let mut p = s.utf16_units().collect::<Vec<u16>>();
+                p.push(0);
+                p
+            }
             None => return false,
         };
         unsafe {
@@ -1100,8 +1105,7 @@ unsafe fn load_argc_and_argv(argc: int,
     use c_str::CString;
 
     Vec::from_fn(argc as uint, |i| {
-        Vec::from_slice(CString::new(*argv.offset(i as int),
-                                     false).as_bytes_no_nul())
+        CString::new(*argv.offset(i as int), false).as_bytes_no_nul().to_vec()
     })
 }
 
@@ -1170,7 +1174,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
                 mem::transmute(objc_msgSend(tmp, utf8Sel));
             let s = CString::new(utf_c_str, false);
             if s.is_not_null() {
-                res.push(Vec::from_slice(s.as_bytes_no_nul()))
+                res.push(s.as_bytes_no_nul().to_vec())
             }
         }
     }
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index d84848545bd..16552daae36 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -76,7 +76,7 @@ use option::{Option, None, Some};
 use str;
 use str::{MaybeOwned, Str, StrSlice};
 use string::String;
-use slice::Slice;
+use slice::{Slice, CloneableVector};
 use slice::{ImmutablePartialEqSlice, ImmutableSlice};
 use vec::Vec;
 
@@ -480,7 +480,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
             let extlen = extension.container_as_bytes().len();
             match (name.rposition_elem(&dot), extlen) {
                 (None, 0) | (Some(0), 0) => None,
-                (Some(idx), 0) => Some(Vec::from_slice(name.slice_to(idx))),
+                (Some(idx), 0) => Some(name.slice_to(idx).to_vec()),
                 (idx, extlen) => {
                     let idx = match idx {
                         None | Some(0) => name.len(),
@@ -798,7 +798,7 @@ pub trait BytesContainer {
     /// Consumes the receiver and converts it into Vec<u8>
     #[inline]
     fn container_into_owned_bytes(self) -> Vec<u8> {
-        Vec::from_slice(self.container_as_bytes())
+        self.container_as_bytes().to_vec()
     }
     /// Returns the receiver interpreted as a utf-8 string, if possible
     #[inline]
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 7d3c7ea71f6..9c4139853c5 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -399,7 +399,7 @@ impl Path {
             }
         };
         match val {
-            None => Vec::from_slice(v.as_slice()),
+            None => v.as_slice().to_vec(),
             Some(val) => val
         }
     }
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index e703bfae610..3f598e52806 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -371,7 +371,7 @@ impl GenericPath for Path {
 
     #[inline]
     fn into_vec(self) -> Vec<u8> {
-        Vec::from_slice(self.repr.as_bytes())
+        self.repr.into_bytes()
     }
 
     #[inline]
@@ -815,12 +815,14 @@ impl Path {
                         let mut s = String::with_capacity(n);
                         match prefix {
                             Some(DiskPrefix) => {
-                                s.push_char(prefix_.as_bytes()[0].to_ascii().to_uppercase().to_char());
+                                s.push_char(prefix_.as_bytes()[0].to_ascii()
+                                                   .to_uppercase().to_char());
                                 s.push_char(':');
                             }
                             Some(VerbatimDiskPrefix) => {
                                 s.push_str(prefix_.slice_to(4));
-                                s.push_char(prefix_.as_bytes()[4].to_ascii().to_uppercase().to_char());
+                                s.push_char(prefix_.as_bytes()[4].to_ascii()
+                                                   .to_uppercase().to_char());
                                 s.push_str(prefix_.slice_from(5));
                             }
                             Some(UNCPrefix(a,b)) => {
@@ -1619,7 +1621,7 @@ mod tests {
         t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e");
         t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e");
         t!(v: b"a\\b\\c", [b"d", b"\\e", b"f"], b"\\e\\f");
-        t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")],
+        t!(v: b"a\\b\\c", [b"d".to_vec(), b"e".to_vec()],
            b"a\\b\\c\\d\\e");
     }
 
@@ -1759,7 +1761,7 @@ mod tests {
         t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
         t!(s: "a\\b\\c", ["d".to_string(), "e".to_string()], "a\\b\\c\\d\\e");
         t!(v: b"a\\b\\c", [b"d", b"e"], b"a\\b\\c\\d\\e");
-        t!(v: b"a\\b\\c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")],
+        t!(v: b"a\\b\\c", [b"d".to_vec(), b"e".to_vec()],
            b"a\\b\\c\\d\\e");
     }