about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-04-17 15:28:14 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-04-18 10:06:24 -0700
commit7d3b0bf3912fabf52fdd6926900e578e55af1b49 (patch)
tree8405cde2a32e6a2499b9262b5dff6dcb34f36d32
parentce2bab68d69ee04e17c0165dbdb7b583d5a7c991 (diff)
downloadrust-7d3b0bf3912fabf52fdd6926900e578e55af1b49.tar.gz
rust-7d3b0bf3912fabf52fdd6926900e578e55af1b49.zip
std: Make ~[T] no longer a growable vector
This removes all resizability support for ~[T] vectors in preparation of DST.
The only growable vector remaining is Vec<T>. In summary, the following methods
from ~[T] and various functions were removed. Each method/function has an
equivalent on the Vec type in std::vec unless otherwise stated.

* slice::OwnedCloneableVector
* slice::OwnedEqVector
* slice::append
* slice::append_one
* slice::build (no replacement)
* slice::bytes::push_bytes
* slice::from_elem
* slice::from_fn
* slice::with_capacity
* ~[T].capacity()
* ~[T].clear()
* ~[T].dedup()
* ~[T].extend()
* ~[T].grow()
* ~[T].grow_fn()
* ~[T].grow_set()
* ~[T].insert()
* ~[T].pop()
* ~[T].push()
* ~[T].push_all()
* ~[T].push_all_move()
* ~[T].remove()
* ~[T].reserve()
* ~[T].reserve_additional()
* ~[T].reserve_exect()
* ~[T].retain()
* ~[T].set_len()
* ~[T].shift()
* ~[T].shrink_to_fit()
* ~[T].swap_remove()
* ~[T].truncate()
* ~[T].unshift()
* ~str.clear()
* ~str.set_len()
* ~str.truncate()

Note that no other API changes were made. Existing apis that took or returned
~[T] continue to do so.

[breaking-change]
-rw-r--r--src/libstd/comm/shared.rs1
-rw-r--r--src/libstd/comm/stream.rs1
-rw-r--r--src/libstd/hash/sip.rs11
-rw-r--r--src/libstd/io/buffered.rs6
-rw-r--r--src/libstd/io/extensions.rs11
-rw-r--r--src/libstd/io/mem.rs2
-rw-r--r--src/libstd/io/mod.rs4
-rw-r--r--src/libstd/io/process.rs8
-rw-r--r--src/libstd/io/signal.rs2
-rw-r--r--src/libstd/local_data.rs2
-rw-r--r--src/libstd/num/int_macros.rs4
-rw-r--r--src/libstd/num/mod.rs3
-rw-r--r--src/libstd/num/strconv.rs42
-rw-r--r--src/libstd/num/uint_macros.rs4
-rw-r--r--src/libstd/os.rs25
-rw-r--r--src/libstd/path/mod.rs2
-rw-r--r--src/libstd/path/posix.rs2
-rw-r--r--src/libstd/path/windows.rs2
-rw-r--r--src/libstd/prelude.rs2
-rw-r--r--src/libstd/ptr.rs5
-rw-r--r--src/libstd/repr.rs2
-rw-r--r--src/libstd/rt/args.rs7
-rw-r--r--src/libstd/slice.rs1052
-rw-r--r--src/libstd/str.rs93
-rw-r--r--src/libstd/sync/arc.rs6
-rw-r--r--src/libstd/sync/deque.rs2
-rw-r--r--src/libstd/unstable/sync.rs2
-rw-r--r--src/libstd/vec.rs38
28 files changed, 342 insertions, 999 deletions
diff --git a/src/libstd/comm/shared.rs b/src/libstd/comm/shared.rs
index 525786f5d1e..c0f1aeae26b 100644
--- a/src/libstd/comm/shared.rs
+++ b/src/libstd/comm/shared.rs
@@ -30,7 +30,6 @@ use rt::task::{Task, BlockedTask};
 use rt::thread::Thread;
 use sync::atomics;
 use unstable::mutex::NativeMutex;
-use slice::OwnedVector;
 
 use mpsc = sync::mpsc_queue;
 
diff --git a/src/libstd/comm/stream.rs b/src/libstd/comm/stream.rs
index 6c9280e0abc..44070dc4460 100644
--- a/src/libstd/comm/stream.rs
+++ b/src/libstd/comm/stream.rs
@@ -30,7 +30,6 @@ use rt::task::{Task, BlockedTask};
 use rt::thread::Thread;
 use spsc = sync::spsc_queue;
 use sync::atomics;
-use slice::OwnedVector;
 
 static DISCONNECTED: int = int::MIN;
 #[cfg(test)]
diff --git a/src/libstd/hash/sip.rs b/src/libstd/hash/sip.rs
index 9afb7124c4b..eee8e416231 100644
--- a/src/libstd/hash/sip.rs
+++ b/src/libstd/hash/sip.rs
@@ -359,13 +359,8 @@ pub fn hash_with_keys<T: Hash<SipState>>(k0: u64, k1: u64, value: &T) -> u64 {
 #[cfg(test)]
 mod tests {
     extern crate test;
-    use io::Writer;
-    use iter::Iterator;
+    use prelude::*;
     use num::ToStrRadix;
-    use option::{Some, None};
-    use str::Str;
-    use strbuf::StrBuf;
-    use slice::{Vector, ImmutableVector, OwnedVector};
     use self::test::Bencher;
 
     use super::super::Hash;
@@ -454,7 +449,7 @@ mod tests {
 
         let k0 = 0x_07_06_05_04_03_02_01_00_u64;
         let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08_u64;
-        let mut buf : ~[u8] = ~[];
+        let mut buf = Vec::new();
         let mut t = 0;
         let mut state_inc = SipState::new_with_keys(k0, k1);
         let mut state_full = SipState::new_with_keys(k0, k1);
@@ -496,7 +491,7 @@ mod tests {
             assert_eq!(vec, out);
 
             state_full.reset();
-            state_full.write(buf);
+            state_full.write(buf.as_slice());
             let f = result_str(state_full.result());
             let i = result_str(state_inc.result());
             let v = to_hex_str(&vecs[t]);
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index e7d0c03551f..c541eb91d06 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -17,7 +17,7 @@ use iter::ExactSize;
 use ops::Drop;
 use option::{Some, None, Option};
 use result::{Ok, Err};
-use slice::{OwnedVector, ImmutableVector, MutableVector};
+use slice::{ImmutableVector, MutableVector};
 use slice;
 use vec::Vec;
 
@@ -391,7 +391,7 @@ mod test {
 
     /// A dummy reader intended at testing short-reads propagation.
     pub struct ShortReader {
-        lengths: ~[uint],
+        lengths: Vec<uint>,
     }
 
     impl Reader for ShortReader {
@@ -554,7 +554,7 @@ mod test {
 
     #[test]
     fn test_short_reads() {
-        let inner = ShortReader{lengths: ~[0, 1, 2, 0, 1, 0]};
+        let inner = ShortReader{lengths: vec![0, 1, 2, 0, 1, 0]};
         let mut reader = BufferedReader::new(inner);
         let mut buf = [0, 0];
         assert_eq!(reader.read(buf), Ok(0));
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs
index d8022b1e26c..955d4c07d28 100644
--- a/src/libstd/io/extensions.rs
+++ b/src/libstd/io/extensions.rs
@@ -21,7 +21,7 @@ use option::{Option, Some, None};
 use result::{Ok, Err};
 use io;
 use io::{IoError, IoResult, Reader};
-use slice::{OwnedVector, ImmutableVector, Vector};
+use slice::{ImmutableVector, Vector};
 use ptr::RawPtr;
 
 /// An iterator that reads a single byte on each iteration,
@@ -503,21 +503,22 @@ mod test {
 #[cfg(test)]
 mod bench {
     extern crate test;
-    use self::test::Bencher;
+
     use container::Container;
+    use prelude::*;
+    use self::test::Bencher;
 
     macro_rules! u64_from_be_bytes_bench_impl(
         ($size:expr, $stride:expr, $start_index:expr) =>
         ({
-            use slice;
             use super::u64_from_be_bytes;
 
-            let data = slice::from_fn($stride*100+$start_index, |i| i as u8);
+            let data = Vec::from_fn($stride*100+$start_index, |i| i as u8);
             let mut sum = 0u64;
             b.iter(|| {
                 let mut i = $start_index;
                 while i < data.len() {
-                    sum += u64_from_be_bytes(data, i, $size);
+                    sum += u64_from_be_bytes(data.as_slice(), i, $size);
                     i += $stride;
                 }
             });
diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs
index 36e29700c5d..aa3820bcd1f 100644
--- a/src/libstd/io/mem.rs
+++ b/src/libstd/io/mem.rs
@@ -17,7 +17,7 @@ use result::{Err, Ok};
 use io;
 use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
 use slice;
-use slice::{Vector, ImmutableVector, MutableVector, OwnedCloneableVector};
+use slice::{Vector, ImmutableVector, MutableVector};
 use vec::Vec;
 
 fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> {
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 0ee2da7bb70..6864f18d26c 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -228,11 +228,11 @@ use os;
 use option::{Option, Some, None};
 use path::Path;
 use result::{Ok, Err, Result};
-use str::{StrSlice, OwnedStr};
+use str::StrSlice;
 use str;
 use uint;
 use unstable::finally::try_finally;
-use slice::{Vector, OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector};
+use slice::{Vector, MutableVector, ImmutableVector};
 use vec::Vec;
 
 // Reexports
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index f0b96e2e76c..26ead9e1e53 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -16,6 +16,7 @@ use fmt;
 use io::IoResult;
 use io;
 use libc;
+use mem;
 use rt::rtio::{RtioProcess, IoFactory, LocalIo};
 
 /// Signal a process to exit, without forcibly killing it. Corresponds to
@@ -416,12 +417,7 @@ impl Drop for Process {
         drop(self.stdin.take());
         drop(self.stdout.take());
         drop(self.stderr.take());
-        loop {
-            match self.extra_io.pop() {
-                Some(_) => (),
-                None => break,
-            }
-        }
+        drop(mem::replace(&mut self.extra_io, ~[]));
 
         self.wait();
     }
diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs
index d3f3d888b87..e7dae59acb8 100644
--- a/src/libstd/io/signal.rs
+++ b/src/libstd/io/signal.rs
@@ -28,7 +28,7 @@ use mem::drop;
 use option::{Some, None};
 use result::{Ok, Err};
 use rt::rtio::{IoFactory, LocalIo, RtioSignal};
-use slice::{ImmutableVector, OwnedVector};
+use slice::ImmutableVector;
 use vec::Vec;
 
 /// Signals that can be sent and received
diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs
index c76e079432a..78a66f1f762 100644
--- a/src/libstd/local_data.rs
+++ b/src/libstd/local_data.rs
@@ -46,7 +46,7 @@ use kinds::Send;
 use mem::replace;
 use option::{None, Option, Some};
 use rt::task::{Task, LocalStorage};
-use slice::{ImmutableVector, MutableVector, OwnedVector};
+use slice::{ImmutableVector, MutableVector};
 use vec::Vec;
 
 /**
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs
index 1d2c38f22bb..3228b5a1a49 100644
--- a/src/libstd/num/int_macros.rs
+++ b/src/libstd/num/int_macros.rs
@@ -277,13 +277,13 @@ impl ToStrRadix for $T {
     /// Convert to a string in a given base.
     #[inline]
     fn to_str_radix(&self, radix: uint) -> ~str {
-        let mut buf: ~[u8] = ~[];
+        let mut buf = Vec::new();
         strconv::int_to_str_bytes_common(*self, radix, strconv::SignNeg, |i| {
             buf.push(i);
         });
         // We know we generated valid utf-8, so we don't need to go through that
         // check.
-        unsafe { str::raw::from_utf8_owned(buf) }
+        unsafe { str::raw::from_utf8_owned(buf.move_iter().collect()) }
     }
 }
 
diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs
index 7ddefe9a63d..12befed743a 100644
--- a/src/libstd/num/mod.rs
+++ b/src/libstd/num/mod.rs
@@ -1779,12 +1779,11 @@ mod bench {
     extern crate test;
     use self::test::Bencher;
     use num;
-    use slice;
     use prelude::*;
 
     #[bench]
     fn bench_pow_function(b: &mut Bencher) {
-        let v = slice::from_fn(1024, |n| n);
+        let v = Vec::from_fn(1024, |n| n);
         b.iter(|| {v.iter().fold(0, |old, new| num::pow(old, *new));});
     }
 }
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index 3ce9a3d0764..ffcb129d635 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -10,19 +10,21 @@
 
 #![allow(missing_doc)]
 
+use char;
 use clone::Clone;
 use container::Container;
-use std::cmp::{Ord, Eq};
+use iter::Iterator;
+use num::{NumCast, Zero, One, cast, Int};
+use num::{Round, Float, FPNaN, FPInfinite, ToPrimitive};
+use num;
 use ops::{Add, Sub, Mul, Div, Rem, Neg};
 use option::{None, Option, Some};
-use char;
+use slice::OwnedVector;
+use slice::{CloneableVector, ImmutableVector, MutableVector};
+use std::cmp::{Ord, Eq};
 use str::{StrSlice};
 use str;
-use slice::{CloneableVector, ImmutableVector, MutableVector};
-use slice::OwnedVector;
-use num;
-use num::{NumCast, Zero, One, cast, Int};
-use num::{Round, Float, FPNaN, FPInfinite, ToPrimitive};
+use vec::Vec;
 
 /// A flag that specifies whether to use exponential (scientific) notation.
 pub enum ExponentFormat {
@@ -293,7 +295,7 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
     }
 
     let neg = num < _0 || (negative_zero && _1 / num == Float::neg_infinity());
-    let mut buf: ~[u8] = ~[];
+    let mut buf = Vec::new();
     let radix_gen: T   = cast(radix as int).unwrap();
 
     let (num, exp) = match exp_format {
@@ -411,23 +413,23 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
                     // If reached left end of number, have to
                     // insert additional digit:
                     if i < 0
-                    || buf[i as uint] == '-' as u8
-                    || buf[i as uint] == '+' as u8 {
+                    || *buf.get(i as uint) == '-' as u8
+                    || *buf.get(i as uint) == '+' as u8 {
                         buf.insert((i + 1) as uint, value2ascii(1));
                         break;
                     }
 
                     // Skip the '.'
-                    if buf[i as uint] == '.' as u8 { i -= 1; continue; }
+                    if *buf.get(i as uint) == '.' as u8 { i -= 1; continue; }
 
                     // Either increment the digit,
                     // or set to 0 if max and carry the 1.
-                    let current_digit = ascii2value(buf[i as uint]);
+                    let current_digit = ascii2value(*buf.get(i as uint));
                     if current_digit < (radix - 1) {
-                        buf[i as uint] = value2ascii(current_digit+1);
+                        *buf.get_mut(i as uint) = value2ascii(current_digit+1);
                         break;
                     } else {
-                        buf[i as uint] = value2ascii(0);
+                        *buf.get_mut(i as uint) = value2ascii(0);
                         i -= 1;
                     }
                 }
@@ -444,25 +446,25 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
         let mut i = buf_max_i;
 
         // discover trailing zeros of fractional part
-        while i > start_fractional_digits && buf[i] == '0' as u8 {
+        while i > start_fractional_digits && *buf.get(i) == '0' as u8 {
             i -= 1;
         }
 
         // Only attempt to truncate digits if buf has fractional digits
         if i >= start_fractional_digits {
             // If buf ends with '.', cut that too.
-            if buf[i] == '.' as u8 { i -= 1 }
+            if *buf.get(i) == '.' as u8 { i -= 1 }
 
             // only resize buf if we actually remove digits
             if i < buf_max_i {
-                buf = buf.slice(0, i + 1).to_owned();
+                buf = Vec::from_slice(buf.slice(0, i + 1));
             }
         }
     } // If exact and trailing '.', just cut that
     else {
         let max_i = buf.len() - 1;
-        if buf[max_i] == '.' as u8 {
-            buf = buf.slice(0, max_i).to_owned();
+        if *buf.get(max_i) == '.' as u8 {
+            buf = Vec::from_slice(buf.slice(0, max_i));
         }
     }
 
@@ -481,7 +483,7 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
         }
     }
 
-    (buf, false)
+    (buf.move_iter().collect(), false)
 }
 
 /**
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index ece30e72e06..61723f339ae 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -191,13 +191,13 @@ impl ToStrRadix for $T {
     /// Convert to a string in a given base.
     #[inline]
     fn to_str_radix(&self, radix: uint) -> ~str {
-        let mut buf = ~[];
+        let mut buf = Vec::new();
         strconv::int_to_str_bytes_common(*self, radix, strconv::SignNone, |i| {
             buf.push(i);
         });
         // We know we generated valid utf-8, so we don't need to go through that
         // check.
-        unsafe { str::raw::from_utf8_owned(buf) }
+        unsafe { str::raw::from_utf8_owned(buf.move_iter().collect()) }
     }
 }
 
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 25f503174bc..417bf31c13b 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -28,7 +28,6 @@
 
 #![allow(missing_doc)]
 
-#[cfg(target_os = "macos")]
 #[cfg(windows)]
 use iter::range;
 
@@ -49,6 +48,7 @@ use path::{Path, GenericPath};
 use iter::Iterator;
 use slice::{Vector, CloneableVector, ImmutableVector, MutableVector, OwnedVector};
 use ptr::RawPtr;
+use vec::Vec;
 
 #[cfg(unix)]
 use c_str::ToCStr;
@@ -203,7 +203,7 @@ pub fn env_as_bytes() -> ~[(~[u8],~[u8])] {
             result
         }
         #[cfg(unix)]
-        unsafe fn get_env_pairs() -> ~[~[u8]] {
+        unsafe fn get_env_pairs() -> Vec<~[u8]> {
             use c_str::CString;
 
             extern {
@@ -214,7 +214,7 @@ pub fn env_as_bytes() -> ~[(~[u8],~[u8])] {
                 fail!("os::env() failure getting env string from OS: {}",
                        os::last_os_error());
             }
-            let mut result = ~[];
+            let mut result = Vec::new();
             ptr::array_each(environ, |e| {
                 let env_pair = CString::new(e, false).as_bytes_no_nul().to_owned();
                 result.push(env_pair);
@@ -222,8 +222,8 @@ pub fn env_as_bytes() -> ~[(~[u8],~[u8])] {
             result
         }
 
-        fn env_convert(input: ~[~[u8]]) -> ~[(~[u8], ~[u8])] {
-            let mut pairs = ~[];
+        fn env_convert(input: Vec<~[u8]>) -> Vec<(~[u8], ~[u8])> {
+            let mut pairs = Vec::new();
             for p in input.iter() {
                 let vs: ~[&[u8]] = p.splitn(1, |b| *b == '=' as u8).collect();
                 let key = vs[0].to_owned();
@@ -234,7 +234,7 @@ pub fn env_as_bytes() -> ~[(~[u8],~[u8])] {
         }
         with_env_lock(|| {
             let unparsed_environ = get_env_pairs();
-            env_convert(unparsed_environ)
+            env_convert(unparsed_environ).move_iter().collect()
         })
     }
 }
@@ -457,15 +457,14 @@ pub fn self_exe_name() -> Option<Path> {
     fn load_self() -> Option<~[u8]> {
         unsafe {
             use libc::funcs::extra::_NSGetExecutablePath;
-            use slice;
             let mut sz: u32 = 0;
             _NSGetExecutablePath(ptr::mut_null(), &mut sz);
             if sz == 0 { return None; }
-            let mut v: ~[u8] = slice::with_capacity(sz as uint);
+            let mut v: Vec<u8> = Vec::with_capacity(sz as uint);
             let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
             if err != 0 { return None; }
             v.set_len(sz as uint - 1); // chop off trailing NUL
-            Some(v)
+            Some(v.move_iter().collect())
         }
     }
 
@@ -795,11 +794,9 @@ pub fn get_exit_status() -> int {
 unsafe fn load_argc_and_argv(argc: int, argv: **c_char) -> ~[~[u8]] {
     use c_str::CString;
 
-    let mut args = ~[];
-    for i in range(0u, argc as uint) {
-        args.push(CString::new(*argv.offset(i as int), false).as_bytes_no_nul().to_owned())
-    }
-    args
+    Vec::from_fn(argc as uint, |i| {
+        CString::new(*argv.offset(i as int), false).as_bytes_no_nul().to_owned()
+    }).move_iter().collect()
 }
 
 /**
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 6a1f9c1a4c7..2960d55f337 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -74,7 +74,7 @@ use option::{Option, None, Some};
 use str;
 use str::{MaybeOwned, Str, StrSlice, from_utf8_lossy};
 use strbuf::StrBuf;
-use slice::{OwnedCloneableVector, OwnedVector, Vector};
+use slice::Vector;
 use slice::{ImmutableEqVector, ImmutableVector};
 use vec::Vec;
 
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 1a80e52359d..47f9604d63f 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -21,7 +21,7 @@ use option::{Option, None, Some};
 use str;
 use str::Str;
 use slice::{CloneableVector, RevSplits, Splits, Vector, VectorVector,
-            ImmutableEqVector, OwnedVector, ImmutableVector, OwnedCloneableVector};
+            ImmutableEqVector, OwnedVector, ImmutableVector};
 use vec::Vec;
 
 use super::{BytesContainer, GenericPath, GenericPathUnsafe};
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 435b64e8d2a..58c7aaa2d32 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -21,7 +21,7 @@ use io::Writer;
 use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Rev, Iterator, Map};
 use option::{Option, Some, None};
 use slice::{Vector, OwnedVector, ImmutableVector};
-use str::{CharSplits, OwnedStr, Str, StrVector, StrSlice};
+use str::{CharSplits, Str, StrVector, StrSlice};
 use strbuf::StrBuf;
 use vec::Vec;
 
diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs
index b7bcbefa468..a44b23c4249 100644
--- a/src/libstd/prelude.rs
+++ b/src/libstd/prelude.rs
@@ -56,7 +56,7 @@ pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
 pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
 pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
 pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector, ImmutableCloneableVector};
-pub use slice::{OwnedVector, OwnedCloneableVector, OwnedEqVector};
+pub use slice::{OwnedVector};
 pub use slice::{MutableVector, MutableTotalOrdVector};
 pub use slice::{Vector, VectorVector, CloneableVector, ImmutableVector};
 pub use strbuf::StrBuf;
diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs
index 19eee8755a0..61461096ed9 100644
--- a/src/libstd/ptr.rs
+++ b/src/libstd/ptr.rs
@@ -170,10 +170,9 @@ pub fn mut_null<T>() -> *mut T { 0 as *mut T }
 ///
 /// ```
 /// use std::ptr;
-/// use std::slice;
 ///
-/// unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> ~[T] {
-///     let mut dst = slice::with_capacity(elts);
+/// unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> Vec<T> {
+///     let mut dst = Vec::with_capacity(elts);
 ///     dst.set_len(elts);
 ///     ptr::copy_memory(dst.as_mut_ptr(), ptr, elts);
 ///     dst
diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs
index 7205edee611..61238f508c1 100644
--- a/src/libstd/repr.rs
+++ b/src/libstd/repr.rs
@@ -28,7 +28,7 @@ use reflect::{MovePtr, align};
 use result::{Ok, Err};
 use str::StrSlice;
 use to_str::ToStr;
-use slice::{Vector, OwnedVector};
+use slice::Vector;
 use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
 use raw;
 use vec::Vec;
diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs
index 328de696914..abe2e2ab1dc 100644
--- a/src/libstd/rt/args.rs
+++ b/src/libstd/rt/args.rs
@@ -125,13 +125,14 @@ mod imp {
     unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~[u8]] {
         use c_str::CString;
         use ptr::RawPtr;
-        use {slice, libc};
+        use libc;
         use slice::CloneableVector;
+        use vec::Vec;
 
-        slice::from_fn(argc as uint, |i| {
+        Vec::from_fn(argc as uint, |i| {
             let cs = CString::new(*(argv as **libc::c_char).offset(i as int), false);
             cs.as_bytes_no_nul().to_owned()
-        })
+        }).move_iter().collect()
     }
 
     #[cfg(test)]
diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs
index 153e21c780c..4210b2ec670 100644
--- a/src/libstd/slice.rs
+++ b/src/libstd/slice.rs
@@ -54,9 +54,9 @@ An example is the method `.push(element)` that will add an element at the end
 of the vector:
 
 ```rust
-let mut numbers = ~[0, 1, 2];
+let mut numbers = vec![0, 1, 2];
 numbers.push(7);
-// numbers is now ~[0, 1, 2, 7];
+// numbers is now vec![0, 1, 2, 7];
  ```
 
 ## Implementations of other traits
@@ -99,117 +99,31 @@ There are a number of free functions that create or take vectors, for example:
 
 */
 
-#![warn(non_camel_case_types)]
-
 use cast;
 use cast::transmute;
 use ops::Drop;
 use clone::Clone;
-use container::{Container, Mutable};
+use container::Container;
 use cmp::{Eq, TotalOrd, Ordering, Less, Equal, Greater};
 use cmp;
 use default::Default;
 use fmt;
 use iter::*;
-use num::{CheckedAdd, Saturating, checked_next_power_of_two, div_rem};
+use num::{CheckedAdd, Saturating, div_rem};
+use num::CheckedMul;
 use option::{None, Option, Some};
 use ptr;
 use ptr::RawPtr;
-use rt::global_heap::{malloc_raw, realloc_raw, exchange_free};
+use rt::global_heap::{malloc_raw, exchange_free};
 use result::{Ok, Err};
 use mem;
 use mem::size_of;
 use kinds::marker;
 use uint;
 use unstable::finally::try_finally;
-use raw::{Repr, Slice, Vec};
-
-/**
- * Creates and initializes an owned vector.
- *
- * Creates an owned vector of size `n_elts` and initializes the elements
- * to the value returned by the function `op`.
- */
-pub fn from_fn<T>(n_elts: uint, op: |uint| -> T) -> ~[T] {
-    unsafe {
-        let mut v = with_capacity(n_elts);
-        let p = v.as_mut_ptr();
-        let mut i = 0;
-        try_finally(
-            &mut i, (),
-            |i, ()| while *i < n_elts {
-                mem::move_val_init(
-                    &mut(*p.offset(*i as int)),
-                    op(*i));
-                *i += 1u;
-            },
-            |i| v.set_len(*i));
-        v
-    }
-}
-
-/**
- * Creates and initializes an owned vector.
- *
- * Creates an owned vector of size `n_elts` and initializes the elements
- * to the value `t`.
- */
-pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
-    // FIXME (#7136): manually inline from_fn for 2x plus speedup (sadly very
-    // important, from_elem is a bottleneck in borrowck!). Unfortunately it
-    // still is substantially slower than using the unsafe
-    // slice::with_capacity/ptr::set_memory for primitive types.
-    unsafe {
-        let mut v = with_capacity(n_elts);
-        let p = v.as_mut_ptr();
-        let mut i = 0u;
-        try_finally(
-            &mut i, (),
-            |i, ()| while *i < n_elts {
-                mem::move_val_init(
-                    &mut(*p.offset(*i as int)),
-                    t.clone());
-                *i += 1u;
-            },
-            |i| v.set_len(*i));
-        v
-    }
-}
-
-/// Creates a new vector with a capacity of `capacity`
-#[inline]
-pub fn with_capacity<T>(capacity: uint) -> ~[T] {
-    unsafe {
-        let alloc = capacity * mem::nonzero_size_of::<T>();
-        let size = alloc + mem::size_of::<Vec<()>>();
-        if alloc / mem::nonzero_size_of::<T>() != capacity || size < alloc {
-            fail!("vector size is too large: {}", capacity);
-        }
-        let ptr = malloc_raw(size) as *mut Vec<()>;
-        (*ptr).alloc = alloc;
-        (*ptr).fill = 0;
-        transmute(ptr)
-    }
-}
-
-/**
- * Builds a vector by calling a provided function with an argument
- * function that pushes an element to the back of a vector.
- * The initial capacity for the vector may optionally be specified.
- *
- * # Arguments
- *
- * * size - An option, maybe containing initial size of the vector to reserve
- * * builder - A function that will construct the vector. It receives
- *             as an argument a function that will push an element
- *             onto the vector being constructed.
- */
-#[inline]
-pub fn build<A>(size: Option<uint>, builder: |push: |v: A||) -> ~[A] {
-    let mut vec = with_capacity(size.unwrap_or(4));
-    builder(|x| vec.push(x));
-    vec
-}
+use raw::{Repr, Slice};
+use RawVec = raw::Vec;
+use vec::Vec;
 
 /**
  * Converts a pointer to A into a slice of length 1 (without copying).
@@ -326,26 +240,6 @@ impl<'a, T> Iterator<&'a [T]> for RevSplits<'a, T> {
     }
 }
 
-// Appending
-
-/// Iterates over the `rhs` vector, copying each element and appending it to the
-/// `lhs`. Afterwards, the `lhs` is then returned for use again.
-#[inline]
-pub fn append<T:Clone>(lhs: ~[T], rhs: &[T]) -> ~[T] {
-    let mut v = lhs;
-    v.push_all(rhs);
-    v
-}
-
-/// Appends one element to the vector provided. The vector itself is then
-/// returned for use again.
-#[inline]
-pub fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
-    let mut v = lhs;
-    v.push(x);
-    v
-}
-
 // Functional utilities
 
 #[allow(missing_doc)]
@@ -362,22 +256,22 @@ pub trait VectorVector<T> {
 impl<'a, T: Clone, V: Vector<T>> VectorVector<T> for &'a [V] {
     fn concat_vec(&self) -> ~[T] {
         let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
-        let mut result = with_capacity(size);
+        let mut result = Vec::with_capacity(size);
         for v in self.iter() {
             result.push_all(v.as_slice())
         }
-        result
+        result.move_iter().collect()
     }
 
     fn connect_vec(&self, sep: &T) -> ~[T] {
         let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
-        let mut result = with_capacity(size + self.len());
+        let mut result = Vec::with_capacity(size + self.len());
         let mut first = true;
         for v in self.iter() {
             if first { first = false } else { result.push(sep.clone()) }
             result.push_all(v.as_slice())
         }
-        result
+        result.move_iter().collect()
     }
 }
 
@@ -391,13 +285,13 @@ impl<'a, T: Clone, V: Vector<T>> VectorVector<T> for &'a [V] {
  */
 pub fn unzip<T, U, V: Iterator<(T, U)>>(mut iter: V) -> (~[T], ~[U]) {
     let (lo, _) = iter.size_hint();
-    let mut ts = with_capacity(lo);
-    let mut us = with_capacity(lo);
+    let mut ts = Vec::with_capacity(lo);
+    let mut us = Vec::with_capacity(lo);
     for (t, u) in iter {
         ts.push(t);
         us.push(u);
     }
-    (ts, us)
+    (ts.move_iter().collect(), us.move_iter().collect())
 }
 
 /// An Iterator that yields the element swaps needed to produce
@@ -618,8 +512,9 @@ pub mod traits {
     use container::Container;
     use clone::Clone;
     use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Equiv};
-    use iter::order;
+    use iter::{order, Iterator};
     use ops::Add;
+    use vec::Vec;
 
     impl<'a,T:Eq> Eq for &'a [T] {
         fn eq(&self, other: & &'a [T]) -> bool {
@@ -696,10 +591,10 @@ pub mod traits {
     impl<'a,T:Clone, V: Vector<T>> Add<V, ~[T]> for &'a [T] {
         #[inline]
         fn add(&self, rhs: &V) -> ~[T] {
-            let mut res = with_capacity(self.len() + rhs.as_slice().len());
+            let mut res = Vec::with_capacity(self.len() + rhs.as_slice().len());
             res.push_all(*self);
             res.push_all(rhs.as_slice());
-            res
+            res.move_iter().collect()
         }
     }
 
@@ -761,7 +656,7 @@ impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
     #[inline]
     fn to_owned(&self) -> ~[T] {
         let len = self.len();
-        let mut result = with_capacity(len);
+        let mut result = Vec::with_capacity(len);
         // Unsafe code so this can be optimised to a memcpy (or something
         // similarly fast) when T is Copy. LLVM is easily confused, so any
         // extra operations during the loop can prevent this optimisation
@@ -780,7 +675,7 @@ impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
                 },
                 |i| result.set_len(*i));
         }
-        result
+        result.move_iter().collect()
     }
 
     #[inline(always)]
@@ -1215,8 +1110,8 @@ pub trait ImmutableCloneableVector<T> {
 impl<'a,T:Clone> ImmutableCloneableVector<T> for &'a [T] {
     #[inline]
     fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]) {
-        let mut lefts  = ~[];
-        let mut rights = ~[];
+        let mut lefts  = Vec::new();
+        let mut rights = Vec::new();
 
         for elt in self.iter() {
             if f(elt) {
@@ -1226,7 +1121,7 @@ impl<'a,T:Clone> ImmutableCloneableVector<T> for &'a [T] {
             }
         }
 
-        (lefts, rights)
+        (lefts.move_iter().collect(), rights.move_iter().collect())
     }
 
     fn permutations(self) -> Permutations<T> {
@@ -1259,148 +1154,10 @@ pub trait OwnedVector<T> {
     fn move_rev_iter(self) -> RevMoveItems<T>;
 
     /**
-     * Reserves capacity for exactly `n` elements in the given vector.
-     *
-     * If the capacity for `self` is already equal to or greater than the requested
-     * capacity, then no action is taken.
-     *
-     * # Arguments
-     *
-     * * n - The number of elements to reserve space for
-     *
-     * # Failure
-     *
-     * This method always succeeds in reserving space for `n` elements, or it does
-     * not return.
-     */
-    fn reserve_exact(&mut self, n: uint);
-    /**
-     * Reserves capacity for at least `n` elements in the given vector.
-     *
-     * This function will over-allocate in order to amortize the allocation costs
-     * in scenarios where the caller may need to repeatedly reserve additional
-     * space.
-     *
-     * If the capacity for `self` is already equal to or greater than the requested
-     * capacity, then no action is taken.
-     *
-     * # Arguments
-     *
-     * * n - The number of elements to reserve space for
-     */
-    fn reserve(&mut self, n: uint);
-    /**
-     * Reserves capacity for at least `n` additional elements in the given vector.
-     *
-     * # Failure
-     *
-     * Fails if the new required capacity overflows uint.
-     *
-     * May also fail if `reserve` fails.
-     */
-    fn reserve_additional(&mut self, n: uint);
-    /// Returns the number of elements the vector can hold without reallocating.
-    fn capacity(&self) -> uint;
-    /// Shrink the capacity of the vector to match the length
-    fn shrink_to_fit(&mut self);
-
-    /// Append an element to a vector
-    fn push(&mut self, t: T);
-    /// Takes ownership of the vector `rhs`, moving all elements into
-    /// the current vector. This does not copy any elements, and it is
-    /// illegal to use the `rhs` vector after calling this method
-    /// (because it is moved here).
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let mut a = ~[~1];
-    /// a.push_all_move(~[~2, ~3, ~4]);
-    /// assert!(a == ~[~1, ~2, ~3, ~4]);
-    /// ```
-    fn push_all_move(&mut self, rhs: ~[T]);
-    /// Remove the last element from a vector and return it, or `None` if it is empty
-    fn pop(&mut self) -> Option<T>;
-    /// Removes the first element from a vector and return it, or `None` if it is empty
-    fn shift(&mut self) -> Option<T>;
-    /// Prepend an element to the vector
-    fn unshift(&mut self, x: T);
-
-    /// Insert an element at position i within v, shifting all
-    /// elements after position i one position to the right.
-    fn insert(&mut self, i: uint, x:T);
-
-    /// Remove and return the element at position `i` within `v`,
-    /// shifting all elements after position `i` one position to the
-    /// left. Returns `None` if `i` is out of bounds.
-    ///
-    /// # Example
-    /// ```rust
-    /// let mut v = ~[1, 2, 3];
-    /// assert_eq!(v.remove(1), Some(2));
-    /// assert_eq!(v, ~[1, 3]);
-    ///
-    /// assert_eq!(v.remove(4), None);
-    /// // v is unchanged:
-    /// assert_eq!(v, ~[1, 3]);
-    /// ```
-    fn remove(&mut self, i: uint) -> Option<T>;
-
-    /// Remove an element from anywhere in the vector and return it, replacing it
-    /// with the last element. This does not preserve ordering, but is O(1).
-    ///
-    /// Returns `None` if `index` is out of bounds.
-    ///
-    /// # Example
-    /// ```rust
-    /// let mut v = ~[~"foo", ~"bar", ~"baz", ~"qux"];
-    ///
-    /// assert_eq!(v.swap_remove(1), Some(~"bar"));
-    /// assert_eq!(v, ~[~"foo", ~"qux", ~"baz"]);
-    ///
-    /// assert_eq!(v.swap_remove(0), Some(~"foo"));
-    /// assert_eq!(v, ~[~"baz", ~"qux"]);
-    ///
-    /// assert_eq!(v.swap_remove(2), None);
-    /// ```
-    fn swap_remove(&mut self, index: uint) -> Option<T>;
-
-    /// Shorten a vector, dropping excess elements.
-    fn truncate(&mut self, newlen: uint);
-
-    /**
-     * Like `filter()`, but in place.  Preserves order of `v`.  Linear time.
-     */
-    fn retain(&mut self, f: |t: &T| -> bool);
-
-    /**
      * Partitions the vector into two vectors `(A,B)`, where all
      * elements of `A` satisfy `f` and all elements of `B` do not.
      */
     fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]);
-
-    /**
-     * Expands a vector in place, initializing the new elements to the result of
-     * a function.
-     *
-     * Function `init_op` is called `n` times with the values [0..`n`)
-     *
-     * # Arguments
-     *
-     * * n - The number of elements to add
-     * * init_op - A function to call to retrieve each appended element's
-     *             value
-     */
-    fn grow_fn(&mut self, n: uint, op: |uint| -> T);
-
-    /**
-     * Sets the length of a vector
-     *
-     * This will explicitly set the size of the vector, without actually
-     * modifying its buffers, so it is up to the caller to ensure that
-     * the vector is actually the specified size.
-     */
-    unsafe fn set_len(&mut self, new_len: uint);
 }
 
 impl<T> OwnedVector<T> for ~[T] {
@@ -1418,202 +1175,10 @@ impl<T> OwnedVector<T> for ~[T] {
         self.move_iter().rev()
     }
 
-    fn reserve_exact(&mut self, n: uint) {
-        // Only make the (slow) call into the runtime if we have to
-        if self.capacity() < n {
-            unsafe {
-                let ptr: *mut *mut Vec<()> = transmute(self);
-                let alloc = n * mem::nonzero_size_of::<T>();
-                let size = alloc + mem::size_of::<Vec<()>>();
-                if alloc / mem::nonzero_size_of::<T>() != n || size < alloc {
-                    fail!("vector size is too large: {}", n);
-                }
-                *ptr = realloc_raw(*ptr as *mut u8, size)
-                                   as *mut Vec<()>;
-                (**ptr).alloc = alloc;
-            }
-        }
-    }
-
-    #[inline]
-    fn reserve(&mut self, n: uint) {
-        self.reserve_exact(checked_next_power_of_two(n).unwrap_or(n));
-    }
-
-    #[inline]
-    fn reserve_additional(&mut self, n: uint) {
-        if self.capacity() - self.len() < n {
-            match self.len().checked_add(&n) {
-                None => fail!("slice::reserve_additional: `uint` overflow"),
-                Some(new_cap) => self.reserve(new_cap)
-            }
-        }
-    }
-
-    #[inline]
-    fn capacity(&self) -> uint {
-        unsafe {
-            let repr: **Vec<()> = transmute(self);
-            (**repr).alloc / mem::nonzero_size_of::<T>()
-        }
-    }
-
-    fn shrink_to_fit(&mut self) {
-        unsafe {
-            let ptr: *mut *mut Vec<()> = transmute(self);
-            let alloc = (**ptr).fill;
-            let size = alloc + mem::size_of::<Vec<()>>();
-            *ptr = realloc_raw(*ptr as *mut u8, size) as *mut Vec<()>;
-            (**ptr).alloc = alloc;
-        }
-    }
-
-    #[inline]
-    fn push(&mut self, t: T) {
-        unsafe {
-            let repr: **Vec<()> = transmute(&mut *self);
-            let fill = (**repr).fill;
-            if (**repr).alloc <= fill {
-                self.reserve_additional(1);
-            }
-
-            push_fast(self, t);
-        }
-
-        // This doesn't bother to make sure we have space.
-        #[inline] // really pretty please
-        unsafe fn push_fast<T>(this: &mut ~[T], t: T) {
-            let repr: **mut Vec<u8> = transmute(this);
-            let fill = (**repr).fill;
-            (**repr).fill += mem::nonzero_size_of::<T>();
-            let p = &((**repr).data) as *u8;
-            let p = p.offset(fill as int) as *mut T;
-            mem::move_val_init(&mut(*p), t);
-        }
-    }
-
-    #[inline]
-    fn push_all_move(&mut self, mut rhs: ~[T]) {
-        let self_len = self.len();
-        let rhs_len = rhs.len();
-        let new_len = self_len + rhs_len;
-        self.reserve_additional(rhs.len());
-        unsafe { // Note: infallible.
-            let self_p = self.as_mut_ptr();
-            let rhs_p = rhs.as_ptr();
-            ptr::copy_memory(self_p.offset(self_len as int), rhs_p, rhs_len);
-            self.set_len(new_len);
-            rhs.set_len(0);
-        }
-    }
-
-    fn pop(&mut self) -> Option<T> {
-        match self.len() {
-            0  => None,
-            ln => {
-                let valptr = &mut self[ln - 1u] as *mut T;
-                unsafe {
-                    self.set_len(ln - 1u);
-                    Some(ptr::read(&*valptr))
-                }
-            }
-        }
-    }
-
-
-    #[inline]
-    fn shift(&mut self) -> Option<T> {
-        self.remove(0)
-    }
-
-    #[inline]
-    fn unshift(&mut self, x: T) {
-        self.insert(0, x)
-    }
-
-    fn insert(&mut self, i: uint, x: T) {
-        let len = self.len();
-        assert!(i <= len);
-        // space for the new element
-        self.reserve_additional(1);
-
-        unsafe { // infallible
-            // The spot to put the new value
-            let p = self.as_mut_ptr().offset(i as int);
-            // Shift everything over to make space. (Duplicating the
-            // `i`th element into two consecutive places.)
-            ptr::copy_memory(p.offset(1), &*p, len - i);
-            // Write it in, overwriting the first copy of the `i`th
-            // element.
-            mem::move_val_init(&mut *p, x);
-            self.set_len(len + 1);
-        }
-    }
-
-    fn remove(&mut self, i: uint) -> Option<T> {
-        let len = self.len();
-        if i < len {
-            unsafe { // infallible
-                // the place we are taking from.
-                let ptr = self.as_mut_ptr().offset(i as int);
-                // copy it out, unsafely having a copy of the value on
-                // the stack and in the vector at the same time.
-                let ret = Some(ptr::read(ptr as *T));
-
-                // Shift everything down to fill in that spot.
-                ptr::copy_memory(ptr, &*ptr.offset(1), len - i - 1);
-                self.set_len(len - 1);
-
-                ret
-            }
-        } else {
-            None
-        }
-    }
-    fn swap_remove(&mut self, index: uint) -> Option<T> {
-        let ln = self.len();
-        if index < ln - 1 {
-            self.swap(index, ln - 1);
-        } else if index >= ln {
-            return None
-        }
-        self.pop()
-    }
-    fn truncate(&mut self, newlen: uint) {
-        let oldlen = self.len();
-        assert!(newlen <= oldlen);
-
-        unsafe {
-            let p = self.as_mut_ptr();
-            // This loop is optimized out for non-drop types.
-            for i in range(newlen, oldlen) {
-                ptr::read_and_zero(p.offset(i as int));
-            }
-        }
-        unsafe { self.set_len(newlen); }
-    }
-
-    fn retain(&mut self, f: |t: &T| -> bool) {
-        let len = self.len();
-        let mut deleted: uint = 0;
-
-        for i in range(0u, len) {
-            if !f(&self[i]) {
-                deleted += 1;
-            } else if deleted > 0 {
-                self.swap(i - deleted, i);
-            }
-        }
-
-        if deleted > 0 {
-            self.truncate(len - deleted);
-        }
-    }
-
     #[inline]
     fn partition(self, f: |&T| -> bool) -> (~[T], ~[T]) {
-        let mut lefts  = ~[];
-        let mut rights = ~[];
+        let mut lefts  = Vec::new();
+        let mut rights = Vec::new();
 
         for elt in self.move_iter() {
             if f(&elt) {
@@ -1623,184 +1188,7 @@ impl<T> OwnedVector<T> for ~[T] {
             }
         }
 
-        (lefts, rights)
-    }
-    fn grow_fn(&mut self, n: uint, op: |uint| -> T) {
-        let new_len = self.len() + n;
-        self.reserve(new_len);
-        let mut i: uint = 0u;
-        while i < n {
-            self.push(op(i));
-            i += 1u;
-        }
-    }
-
-    #[inline]
-    unsafe fn set_len(&mut self, new_len: uint) {
-        let repr: **mut Vec<()> = transmute(self);
-        (**repr).fill = new_len * mem::nonzero_size_of::<T>();
-    }
-}
-
-impl<T> Mutable for ~[T] {
-    /// Clear the vector, removing all values.
-    fn clear(&mut self) { self.truncate(0) }
-}
-
-/// Extension methods for owned vectors containing `Clone` elements.
-pub trait OwnedCloneableVector<T:Clone> {
-    /// Iterates over the slice `rhs`, copies each element, and then appends it to
-    /// the vector provided `v`. The `rhs` vector is traversed in-order.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let mut a = ~[1];
-    /// a.push_all([2, 3, 4]);
-    /// assert!(a == ~[1, 2, 3, 4]);
-    /// ```
-    fn push_all(&mut self, rhs: &[T]);
-
-    /**
-     * Expands a vector in place, initializing the new elements to a given value
-     *
-     * # Arguments
-     *
-     * * n - The number of elements to add
-     * * initval - The value for the new elements
-     */
-    fn grow(&mut self, n: uint, initval: &T);
-
-    /**
-     * Sets the value of a vector element at a given index, growing the vector as
-     * needed
-     *
-     * Sets the element at position `index` to `val`. If `index` is past the end
-     * of the vector, expands the vector by replicating `initval` to fill the
-     * intervening space.
-     */
-    fn grow_set(&mut self, index: uint, initval: &T, val: T);
-}
-
-impl<T:Clone> OwnedCloneableVector<T> for ~[T] {
-    #[inline]
-    fn push_all(&mut self, rhs: &[T]) {
-        let new_len = self.len() + rhs.len();
-        self.reserve_exact(new_len);
-
-        for elt in rhs.iter() {
-            self.push((*elt).clone())
-        }
-    }
-    fn grow(&mut self, n: uint, initval: &T) {
-        let new_len = self.len() + n;
-        self.reserve(new_len);
-        let mut i: uint = 0u;
-
-        while i < n {
-            self.push((*initval).clone());
-            i += 1u;
-        }
-    }
-    fn grow_set(&mut self, index: uint, initval: &T, val: T) {
-        let l = self.len();
-        if index >= l { self.grow(index - l + 1u, initval); }
-        self[index] = val;
-    }
-}
-
-/// Extension methods for owned vectors containing `Eq` elements.
-pub trait OwnedEqVector<T:Eq> {
-    /**
-    * Remove consecutive repeated elements from a vector; if the vector is
-    * sorted, this removes all duplicates.
-    */
-    fn dedup(&mut self);
-}
-
-impl<T:Eq> OwnedEqVector<T> for ~[T] {
-    fn dedup(&mut self) {
-        unsafe {
-            // Although we have a mutable reference to `self`, we cannot make
-            // *arbitrary* changes. The `Eq` comparisons could fail, so we
-            // must ensure that the vector is in a valid state at all time.
-            //
-            // The way that we handle this is by using swaps; we iterate
-            // over all the elements, swapping as we go so that at the end
-            // the elements we wish to keep are in the front, and those we
-            // wish to reject are at the back. We can then truncate the
-            // vector. This operation is still O(n).
-            //
-            // Example: We start in this state, where `r` represents "next
-            // read" and `w` represents "next_write`.
-            //
-            //           r
-            //     +---+---+---+---+---+---+
-            //     | 0 | 1 | 1 | 2 | 3 | 3 |
-            //     +---+---+---+---+---+---+
-            //           w
-            //
-            // Comparing self[r] against self[w-1], tis is not a duplicate, so
-            // we swap self[r] and self[w] (no effect as r==w) and then increment both
-            // r and w, leaving us with:
-            //
-            //               r
-            //     +---+---+---+---+---+---+
-            //     | 0 | 1 | 1 | 2 | 3 | 3 |
-            //     +---+---+---+---+---+---+
-            //               w
-            //
-            // Comparing self[r] against self[w-1], this value is a duplicate,
-            // so we increment `r` but leave everything else unchanged:
-            //
-            //                   r
-            //     +---+---+---+---+---+---+
-            //     | 0 | 1 | 1 | 2 | 3 | 3 |
-            //     +---+---+---+---+---+---+
-            //               w
-            //
-            // Comparing self[r] against self[w-1], this is not a duplicate,
-            // so swap self[r] and self[w] and advance r and w:
-            //
-            //                       r
-            //     +---+---+---+---+---+---+
-            //     | 0 | 1 | 2 | 1 | 3 | 3 |
-            //     +---+---+---+---+---+---+
-            //                   w
-            //
-            // Not a duplicate, repeat:
-            //
-            //                           r
-            //     +---+---+---+---+---+---+
-            //     | 0 | 1 | 2 | 3 | 1 | 3 |
-            //     +---+---+---+---+---+---+
-            //                       w
-            //
-            // Duplicate, advance r. End of vec. Truncate to w.
-
-            let ln = self.len();
-            if ln < 1 { return; }
-
-            // Avoid bounds checks by using unsafe pointers.
-            let p = self.as_mut_ptr();
-            let mut r = 1;
-            let mut w = 1;
-
-            while r < ln {
-                let p_r = p.offset(r as int);
-                let p_wm1 = p.offset((w - 1) as int);
-                if *p_r != *p_wm1 {
-                    if r != w {
-                        let p_w = p_wm1.offset(1);
-                        mem::swap(&mut *p_r, &mut *p_w);
-                    }
-                    w += 1;
-                }
-                r += 1;
-            }
-
-            self.truncate(w);
-        }
+        (lefts.move_iter().collect(), rights.move_iter().collect())
     }
 }
 
@@ -1872,7 +1260,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
     // length 0 so we can keep shallow copies of the contents of `v`
     // without risking the dtors running on an object twice if
     // `compare` fails.
-    let mut working_space = with_capacity(2 * len);
+    let mut working_space = Vec::with_capacity(2 * len);
     // these both are buffers of length `len`.
     let mut buf_dat = working_space.as_mut_ptr();
     let mut buf_tmp = unsafe {buf_dat.offset(len as int)};
@@ -2475,10 +1863,12 @@ pub unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] {
 /// Unsafe operations
 pub mod raw {
     use cast::transmute;
-    use ptr;
+    use iter::Iterator;
     use ptr::RawPtr;
-    use slice::{with_capacity, MutableVector, OwnedVector};
+    use ptr;
     use raw::Slice;
+    use slice::{MutableVector, OwnedVector};
+    use vec::Vec;
 
     /**
      * Form a slice from a pointer and length (as a number of units,
@@ -2521,10 +1911,10 @@ pub mod raw {
     // Was in raw, but needs to be called by net_tcp::on_tcp_read_cb
     #[inline]
     pub unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> ~[T] {
-        let mut dst = with_capacity(elts);
+        let mut dst = Vec::with_capacity(elts);
         dst.set_len(elts);
         ptr::copy_memory(dst.as_mut_ptr(), ptr, elts);
-        dst
+        dst.move_iter().collect()
     }
 
     /**
@@ -2556,9 +1946,8 @@ pub mod raw {
 /// Operations on `[u8]`.
 pub mod bytes {
     use container::Container;
-    use slice::{MutableVector, OwnedVector, ImmutableVector};
+    use slice::MutableVector;
     use ptr;
-    use ptr::RawPtr;
 
     /// A trait for operations on mutable `[u8]`s.
     pub trait MutableByteVector {
@@ -2582,19 +1971,6 @@ pub mod bytes {
         // Bound checks are done at .copy_memory.
         unsafe { dst.copy_memory(src) }
     }
-
-    /**
-     * Allocate space in `dst` and append the data to `src`.
-     */
-    #[inline]
-    pub fn push_bytes(dst: &mut ~[u8], src: &[u8]) {
-        let old_len = dst.len();
-        dst.reserve_additional(src.len());
-        unsafe {
-            ptr::copy_memory(dst.as_mut_ptr().offset(old_len as int), src.as_ptr(), src.len());
-            dst.set_len(old_len + src.len());
-        }
-    }
 }
 
 impl<A: Clone> Clone for ~[A] {
@@ -2603,17 +1979,6 @@ impl<A: Clone> Clone for ~[A] {
         // Use the fast to_owned on &[A] for cloning
         self.as_slice().to_owned()
     }
-
-    fn clone_from(&mut self, source: &~[A]) {
-        if self.len() < source.len() {
-            *self = source.clone()
-        } else {
-            self.truncate(source.len());
-            for (x, y) in self.mut_iter().zip(source.iter()) {
-                x.clone_from(y);
-            }
-        }
-    }
 }
 
 impl<'a, T: fmt::Show> fmt::Show for &'a [T] {
@@ -2914,22 +2279,35 @@ pub type RevMoveItems<T> = Rev<MoveItems<T>>;
 
 impl<A> FromIterator<A> for ~[A] {
     fn from_iter<T: Iterator<A>>(mut iterator: T) -> ~[A] {
-        let (lower, _) = iterator.size_hint();
-        let mut xs = with_capacity(lower);
-        for x in iterator {
-            xs.push(x);
-        }
-        xs
-    }
-}
+        let mut xs: Vec<A> = iterator.collect();
 
-impl<A> Extendable<A> for ~[A] {
-    fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
-        let (lower, _) = iterator.size_hint();
-        let len = self.len();
-        self.reserve_exact(len + lower);
-        for x in iterator {
-            self.push(x);
+        // Must shrink so the capacity is the same as the length. The length of
+        // the ~[T] vector must exactly match the length of the allocation.
+        xs.shrink_to_fit();
+
+        let len = xs.len();
+        assert!(len == xs.capacity());
+        let data = xs.as_mut_ptr();
+
+        let data_size = len.checked_mul(&mem::size_of::<A>());
+        let data_size = data_size.expect("overflow in from_iter()");
+        let size = mem::size_of::<RawVec<()>>().checked_add(&data_size);
+        let size = size.expect("overflow in from_iter()");
+
+
+        // This is some terribly awful code. Note that all of this will go away
+        // with DST because creating ~[T] from Vec<T> will just be some pointer
+        // swizzling.
+        unsafe {
+            let ret = malloc_raw(size) as *mut RawVec<()>;
+
+            (*ret).fill = len * mem::nonzero_size_of::<A>();
+            (*ret).alloc = len * mem::nonzero_size_of::<A>();
+            ptr::copy_nonoverlapping_memory(&mut (*ret).data as *mut _ as *mut u8,
+                                            data as *u8,
+                                            data_size);
+            xs.set_len(0); // ownership has been transferred
+            cast::transmute(ret)
         }
     }
 }
@@ -2974,38 +2352,50 @@ mod tests {
     #[test]
     fn test_from_fn() {
         // Test on-stack from_fn.
-        let mut v = from_fn(3u, square);
-        assert_eq!(v.len(), 3u);
-        assert_eq!(v[0], 0u);
-        assert_eq!(v[1], 1u);
-        assert_eq!(v[2], 4u);
+        let mut v = Vec::from_fn(3u, square);
+        {
+            let v = v.as_slice();
+            assert_eq!(v.len(), 3u);
+            assert_eq!(v[0], 0u);
+            assert_eq!(v[1], 1u);
+            assert_eq!(v[2], 4u);
+        }
 
         // Test on-heap from_fn.
-        v = from_fn(5u, square);
-        assert_eq!(v.len(), 5u);
-        assert_eq!(v[0], 0u);
-        assert_eq!(v[1], 1u);
-        assert_eq!(v[2], 4u);
-        assert_eq!(v[3], 9u);
-        assert_eq!(v[4], 16u);
+        v = Vec::from_fn(5u, square);
+        {
+            let v = v.as_slice();
+            assert_eq!(v.len(), 5u);
+            assert_eq!(v[0], 0u);
+            assert_eq!(v[1], 1u);
+            assert_eq!(v[2], 4u);
+            assert_eq!(v[3], 9u);
+            assert_eq!(v[4], 16u);
+        }
     }
 
     #[test]
     fn test_from_elem() {
         // Test on-stack from_elem.
-        let mut v = from_elem(2u, 10u);
-        assert_eq!(v.len(), 2u);
-        assert_eq!(v[0], 10u);
-        assert_eq!(v[1], 10u);
+        let mut v = Vec::from_elem(2u, 10u);
+        {
+            let v = v.as_slice();
+            assert_eq!(v.len(), 2u);
+            assert_eq!(v[0], 10u);
+            assert_eq!(v[1], 10u);
+        }
 
         // Test on-heap from_elem.
-        v = from_elem(6u, 20u);
-        assert_eq!(v[0], 20u);
-        assert_eq!(v[1], 20u);
-        assert_eq!(v[2], 20u);
-        assert_eq!(v[3], 20u);
-        assert_eq!(v[4], 20u);
-        assert_eq!(v[5], 20u);
+        v = Vec::from_elem(6u, 20u);
+        {
+            let v = v.as_slice();
+            assert_eq!(v[0], 20u);
+            assert_eq!(v[1], 20u);
+            assert_eq!(v[2], 20u);
+            assert_eq!(v[3], 20u);
+            assert_eq!(v[4], 20u);
+            assert_eq!(v[5], 20u);
+        }
     }
 
     #[test]
@@ -3164,7 +2554,7 @@ mod tests {
 
     #[test]
     fn test_pop() {
-        let mut v = ~[5];
+        let mut v = vec![5];
         let e = v.pop();
         assert_eq!(v.len(), 0);
         assert_eq!(e, Some(5));
@@ -3176,25 +2566,25 @@ mod tests {
 
     #[test]
     fn test_swap_remove() {
-        let mut v = ~[1, 2, 3, 4, 5];
+        let mut v = vec![1, 2, 3, 4, 5];
         let mut e = v.swap_remove(0);
         assert_eq!(e, Some(1));
-        assert_eq!(v, ~[5, 2, 3, 4]);
+        assert_eq!(v, vec![5, 2, 3, 4]);
         e = v.swap_remove(3);
         assert_eq!(e, Some(4));
-        assert_eq!(v, ~[5, 2, 3]);
+        assert_eq!(v, vec![5, 2, 3]);
 
         e = v.swap_remove(3);
         assert_eq!(e, None);
-        assert_eq!(v, ~[5, 2, 3]);
+        assert_eq!(v, vec![5, 2, 3]);
     }
 
     #[test]
     fn test_swap_remove_noncopyable() {
         // Tests that we don't accidentally run destructors twice.
-        let mut v = ~[::unstable::sync::Exclusive::new(()),
-                      ::unstable::sync::Exclusive::new(()),
-                      ::unstable::sync::Exclusive::new(())];
+        let mut v = vec![::unstable::sync::Exclusive::new(()),
+                         ::unstable::sync::Exclusive::new(()),
+                         ::unstable::sync::Exclusive::new(())];
         let mut _e = v.swap_remove(0);
         assert_eq!(v.len(), 2);
         _e = v.swap_remove(1);
@@ -3206,41 +2596,48 @@ mod tests {
     #[test]
     fn test_push() {
         // Test on-stack push().
-        let mut v = ~[];
+        let mut v = vec![];
         v.push(1);
         assert_eq!(v.len(), 1u);
-        assert_eq!(v[0], 1);
+        assert_eq!(v.as_slice()[0], 1);
 
         // Test on-heap push().
         v.push(2);
         assert_eq!(v.len(), 2u);
-        assert_eq!(v[0], 1);
-        assert_eq!(v[1], 2);
+        assert_eq!(v.as_slice()[0], 1);
+        assert_eq!(v.as_slice()[1], 2);
     }
 
     #[test]
     fn test_grow() {
         // Test on-stack grow().
-        let mut v = ~[];
+        let mut v = vec![];
         v.grow(2u, &1);
-        assert_eq!(v.len(), 2u);
-        assert_eq!(v[0], 1);
-        assert_eq!(v[1], 1);
+        {
+            let v = v.as_slice();
+            assert_eq!(v.len(), 2u);
+            assert_eq!(v[0], 1);
+            assert_eq!(v[1], 1);
+        }
 
         // Test on-heap grow().
         v.grow(3u, &2);
-        assert_eq!(v.len(), 5u);
-        assert_eq!(v[0], 1);
-        assert_eq!(v[1], 1);
-        assert_eq!(v[2], 2);
-        assert_eq!(v[3], 2);
-        assert_eq!(v[4], 2);
+        {
+            let v = v.as_slice();
+            assert_eq!(v.len(), 5u);
+            assert_eq!(v[0], 1);
+            assert_eq!(v[1], 1);
+            assert_eq!(v[2], 2);
+            assert_eq!(v[3], 2);
+            assert_eq!(v[4], 2);
+        }
     }
 
     #[test]
     fn test_grow_fn() {
-        let mut v = ~[];
+        let mut v = vec![];
         v.grow_fn(3u, square);
+        let v = v.as_slice();
         assert_eq!(v.len(), 3u);
         assert_eq!(v[0], 0u);
         assert_eq!(v[1], 1u);
@@ -3249,8 +2646,9 @@ mod tests {
 
     #[test]
     fn test_grow_set() {
-        let mut v = ~[1, 2, 3];
+        let mut v = vec![1, 2, 3];
         v.grow_set(4u, &4, 5);
+        let v = v.as_slice();
         assert_eq!(v.len(), 5u);
         assert_eq!(v[0], 1);
         assert_eq!(v[1], 2);
@@ -3261,8 +2659,9 @@ mod tests {
 
     #[test]
     fn test_truncate() {
-        let mut v = ~[~6,~5,~4];
+        let mut v = vec![~6,~5,~4];
         v.truncate(1);
+        let v = v.as_slice();
         assert_eq!(v.len(), 1);
         assert_eq!(*(v[0]), 6);
         // If the unsafe block didn't drop things properly, we blow up here.
@@ -3270,7 +2669,7 @@ mod tests {
 
     #[test]
     fn test_clear() {
-        let mut v = ~[~6,~5,~4];
+        let mut v = vec![~6,~5,~4];
         v.clear();
         assert_eq!(v.len(), 0);
         // If the unsafe block didn't drop things properly, we blow up here.
@@ -3278,28 +2677,28 @@ mod tests {
 
     #[test]
     fn test_dedup() {
-        fn case(a: ~[uint], b: ~[uint]) {
+        fn case(a: Vec<uint>, b: Vec<uint>) {
             let mut v = a;
             v.dedup();
             assert_eq!(v, b);
         }
-        case(~[], ~[]);
-        case(~[1], ~[1]);
-        case(~[1,1], ~[1]);
-        case(~[1,2,3], ~[1,2,3]);
-        case(~[1,1,2,3], ~[1,2,3]);
-        case(~[1,2,2,3], ~[1,2,3]);
-        case(~[1,2,3,3], ~[1,2,3]);
-        case(~[1,1,2,2,2,3,3], ~[1,2,3]);
+        case(vec![], vec![]);
+        case(vec![1], vec![1]);
+        case(vec![1,1], vec![1]);
+        case(vec![1,2,3], vec![1,2,3]);
+        case(vec![1,1,2,3], vec![1,2,3]);
+        case(vec![1,2,2,3], vec![1,2,3]);
+        case(vec![1,2,3,3], vec![1,2,3]);
+        case(vec![1,1,2,2,2,3,3], vec![1,2,3]);
     }
 
     #[test]
     fn test_dedup_unique() {
-        let mut v0 = ~[~1, ~1, ~2, ~3];
+        let mut v0 = vec![~1, ~1, ~2, ~3];
         v0.dedup();
-        let mut v1 = ~[~1, ~2, ~2, ~3];
+        let mut v1 = vec![~1, ~2, ~2, ~3];
         v1.dedup();
-        let mut v2 = ~[~1, ~2, ~3, ~3];
+        let mut v2 = vec![~1, ~2, ~3, ~3];
         v2.dedup();
         /*
          * If the ~pointers were leaked or otherwise misused, valgrind and/or
@@ -3309,11 +2708,11 @@ mod tests {
 
     #[test]
     fn test_dedup_shared() {
-        let mut v0 = ~[~1, ~1, ~2, ~3];
+        let mut v0 = vec![~1, ~1, ~2, ~3];
         v0.dedup();
-        let mut v1 = ~[~1, ~2, ~2, ~3];
+        let mut v1 = vec![~1, ~2, ~2, ~3];
         v1.dedup();
-        let mut v2 = ~[~1, ~2, ~3, ~3];
+        let mut v2 = vec![~1, ~2, ~3, ~3];
         v2.dedup();
         /*
          * If the pointers were leaked or otherwise misused, valgrind and/or
@@ -3323,14 +2722,14 @@ mod tests {
 
     #[test]
     fn test_retain() {
-        let mut v = ~[1, 2, 3, 4, 5];
+        let mut v = vec![1, 2, 3, 4, 5];
         v.retain(is_odd);
-        assert_eq!(v, ~[1, 3, 5]);
+        assert_eq!(v, vec![1, 3, 5]);
     }
 
     #[test]
     fn test_zip_unzip() {
-        let z1 = ~[(1, 4), (2, 5), (3, 6)];
+        let z1 = vec![(1, 4), (2, 5), (3, 6)];
 
         let (left, right) = unzip(z1.iter().map(|&x| x));
 
@@ -3559,9 +2958,9 @@ mod tests {
 
     #[test]
     fn test_shift() {
-        let mut x = ~[1, 2, 3];
+        let mut x = vec![1, 2, 3];
         assert_eq!(x.shift(), Some(1));
-        assert_eq!(&x, &~[2, 3]);
+        assert_eq!(&x, &vec![2, 3]);
         assert_eq!(x.shift(), Some(2));
         assert_eq!(x.shift(), Some(3));
         assert_eq!(x.shift(), None);
@@ -3570,55 +2969,55 @@ mod tests {
 
     #[test]
     fn test_unshift() {
-        let mut x = ~[1, 2, 3];
+        let mut x = vec![1, 2, 3];
         x.unshift(0);
-        assert_eq!(x, ~[0, 1, 2, 3]);
+        assert_eq!(x, vec![0, 1, 2, 3]);
     }
 
     #[test]
     fn test_insert() {
-        let mut a = ~[1, 2, 4];
+        let mut a = vec![1, 2, 4];
         a.insert(2, 3);
-        assert_eq!(a, ~[1, 2, 3, 4]);
+        assert_eq!(a, vec![1, 2, 3, 4]);
 
-        let mut a = ~[1, 2, 3];
+        let mut a = vec![1, 2, 3];
         a.insert(0, 0);
-        assert_eq!(a, ~[0, 1, 2, 3]);
+        assert_eq!(a, vec![0, 1, 2, 3]);
 
-        let mut a = ~[1, 2, 3];
+        let mut a = vec![1, 2, 3];
         a.insert(3, 4);
-        assert_eq!(a, ~[1, 2, 3, 4]);
+        assert_eq!(a, vec![1, 2, 3, 4]);
 
-        let mut a = ~[];
+        let mut a = vec![];
         a.insert(0, 1);
-        assert_eq!(a, ~[1]);
+        assert_eq!(a, vec![1]);
     }
 
     #[test]
     #[should_fail]
     fn test_insert_oob() {
-        let mut a = ~[1, 2, 3];
+        let mut a = vec![1, 2, 3];
         a.insert(4, 5);
     }
 
     #[test]
     fn test_remove() {
-        let mut a = ~[1,2,3,4];
+        let mut a = vec![1,2,3,4];
 
         assert_eq!(a.remove(2), Some(3));
-        assert_eq!(a, ~[1,2,4]);
+        assert_eq!(a, vec![1,2,4]);
 
         assert_eq!(a.remove(2), Some(4));
-        assert_eq!(a, ~[1,2]);
+        assert_eq!(a, vec![1,2]);
 
         assert_eq!(a.remove(2), None);
-        assert_eq!(a, ~[1,2]);
+        assert_eq!(a, vec![1,2]);
 
         assert_eq!(a.remove(0), Some(1));
-        assert_eq!(a, ~[2]);
+        assert_eq!(a, vec![2]);
 
         assert_eq!(a.remove(0), Some(2));
-        assert_eq!(a, ~[]);
+        assert_eq!(a, vec![]);
 
         assert_eq!(a.remove(0), None);
         assert_eq!(a.remove(10), None);
@@ -3626,17 +3025,17 @@ mod tests {
 
     #[test]
     fn test_capacity() {
-        let mut v = ~[0u64];
+        let mut v = vec![0u64];
         v.reserve_exact(10u);
         assert_eq!(v.capacity(), 10u);
-        let mut v = ~[0u32];
+        let mut v = vec![0u32];
         v.reserve_exact(10u);
         assert_eq!(v.capacity(), 10u);
     }
 
     #[test]
     fn test_slice_2() {
-        let v = ~[1, 2, 3, 4, 5];
+        let v = vec![1, 2, 3, 4, 5];
         let v = v.slice(1u, 3u);
         assert_eq!(v.len(), 2u);
         assert_eq!(v[0], 2);
@@ -3647,7 +3046,7 @@ mod tests {
     #[test]
     #[should_fail]
     fn test_from_fn_fail() {
-        from_fn(100, |v| {
+        Vec::from_fn(100, |v| {
             if v == 50 { fail!() }
             ~0
         });
@@ -3674,27 +3073,14 @@ mod tests {
         }
 
         let s = S { f: 0, boxes: (~0, Rc::new(0)) };
-        let _ = from_elem(100, s);
-    }
-
-    #[test]
-    #[should_fail]
-    fn test_build_fail() {
-        use rc::Rc;
-        build(None, |push| {
-            push((~0, Rc::new(0)));
-            push((~0, Rc::new(0)));
-            push((~0, Rc::new(0)));
-            push((~0, Rc::new(0)));
-            fail!();
-        });
+        let _ = Vec::from_elem(100, s);
     }
 
     #[test]
     #[should_fail]
     fn test_grow_fn_fail() {
         use rc::Rc;
-        let mut v = ~[];
+        let mut v = vec![];
         v.grow_fn(100, |i| {
             if i == 50 {
                 fail!()
@@ -4036,6 +3422,7 @@ mod tests {
 
         t!(&[int]);
         t!(~[int]);
+        t!(Vec<int>);
     }
 
     #[test]
@@ -4051,7 +3438,7 @@ mod tests {
     #[test]
     #[should_fail]
     fn test_overflow_does_not_cause_segfault() {
-        let mut v = ~[];
+        let mut v = vec![];
         v.reserve_exact(-1);
         v.push(1);
         v.push(2);
@@ -4061,7 +3448,7 @@ mod tests {
     #[should_fail]
     fn test_overflow_does_not_cause_segfault_managed() {
         use rc::Rc;
-        let mut v = ~[Rc::new(1)];
+        let mut v = vec![Rc::new(1)];
         v.reserve_exact(-1);
         v.push(Rc::new(2));
     }
@@ -4090,7 +3477,7 @@ mod tests {
 
     #[test]
     fn test_iter_zero_sized() {
-        let mut v = ~[Foo, Foo, Foo];
+        let mut v = vec![Foo, Foo, Foo];
         assert_eq!(v.len(), 3);
         let mut cnt = 0;
 
@@ -4118,7 +3505,7 @@ mod tests {
         }
         assert_eq!(cnt, 11);
 
-        let xs = ~[Foo, Foo, Foo];
+        let xs = vec![Foo, Foo, Foo];
         assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()),
                    ~"~[slice::tests::Foo, slice::tests::Foo]");
 
@@ -4135,14 +3522,14 @@ mod tests {
 
     #[test]
     fn test_shrink_to_fit() {
-        let mut xs = ~[0, 1, 2, 3];
+        let mut xs = vec![0, 1, 2, 3];
         for i in range(4, 100) {
             xs.push(i)
         }
         assert_eq!(xs.capacity(), 128);
         xs.shrink_to_fit();
         assert_eq!(xs.capacity(), 100);
-        assert_eq!(xs, range(0, 100).collect::<~[_]>());
+        assert_eq!(xs, range(0, 100).collect::<Vec<_>>());
     }
 
     #[test]
@@ -4300,13 +3687,12 @@ mod bench {
     use prelude::*;
     use ptr;
     use rand::{weak_rng, Rng};
-    use slice;
 
     #[bench]
     fn iterator(b: &mut Bencher) {
         // peculiar numbers to stop LLVM from optimising the summation
         // out.
-        let v = slice::from_fn(100, |i| i ^ (i << 1) ^ (i >> 1));
+        let v = Vec::from_fn(100, |i| i ^ (i << 1) ^ (i >> 1));
 
         b.iter(|| {
             let mut sum = 0;
@@ -4320,7 +3706,7 @@ mod bench {
 
     #[bench]
     fn mut_iterator(b: &mut Bencher) {
-        let mut v = slice::from_elem(100, 0);
+        let mut v = Vec::from_elem(100, 0);
 
         b.iter(|| {
             let mut i = 0;
@@ -4342,23 +3728,23 @@ mod bench {
 
     #[bench]
     fn concat(b: &mut Bencher) {
-        let xss: &[~[uint]] = slice::from_fn(100, |i| range(0, i).collect());
+        let xss: Vec<Vec<uint>> = Vec::from_fn(100, |i| range(0, i).collect());
         b.iter(|| {
-            let _ = xss.concat_vec();
+            xss.as_slice().concat_vec()
         });
     }
 
     #[bench]
     fn connect(b: &mut Bencher) {
-        let xss: &[~[uint]] = slice::from_fn(100, |i| range(0, i).collect());
+        let xss: Vec<Vec<uint>> = Vec::from_fn(100, |i| range(0, i).collect());
         b.iter(|| {
-            let _ = xss.connect_vec(&0);
+            xss.as_slice().connect_vec(&0)
         });
     }
 
     #[bench]
     fn push(b: &mut Bencher) {
-        let mut vec: ~[uint] = ~[0u];
+        let mut vec: Vec<uint> = vec![];
         b.iter(|| {
             vec.push(0);
             &vec
@@ -4367,59 +3753,59 @@ mod bench {
 
     #[bench]
     fn starts_with_same_vector(b: &mut Bencher) {
-        let vec: ~[uint] = slice::from_fn(100, |i| i);
+        let vec: Vec<uint> = Vec::from_fn(100, |i| i);
         b.iter(|| {
-            vec.starts_with(vec)
+            vec.as_slice().starts_with(vec.as_slice())
         })
     }
 
     #[bench]
     fn starts_with_single_element(b: &mut Bencher) {
-        let vec: ~[uint] = ~[0u];
+        let vec: Vec<uint> = vec![0];
         b.iter(|| {
-            vec.starts_with(vec)
+            vec.as_slice().starts_with(vec.as_slice())
         })
     }
 
     #[bench]
     fn starts_with_diff_one_element_at_end(b: &mut Bencher) {
-        let vec: ~[uint] = slice::from_fn(100, |i| i);
-        let mut match_vec: ~[uint] = slice::from_fn(99, |i| i);
+        let vec: Vec<uint> = Vec::from_fn(100, |i| i);
+        let mut match_vec: Vec<uint> = Vec::from_fn(99, |i| i);
         match_vec.push(0);
         b.iter(|| {
-            vec.starts_with(match_vec)
+            vec.as_slice().starts_with(match_vec.as_slice())
         })
     }
 
     #[bench]
     fn ends_with_same_vector(b: &mut Bencher) {
-        let vec: ~[uint] = slice::from_fn(100, |i| i);
+        let vec: Vec<uint> = Vec::from_fn(100, |i| i);
         b.iter(|| {
-            vec.ends_with(vec)
+            vec.as_slice().ends_with(vec.as_slice())
         })
     }
 
     #[bench]
     fn ends_with_single_element(b: &mut Bencher) {
-        let vec: ~[uint] = ~[0u];
+        let vec: Vec<uint> = vec![0];
         b.iter(|| {
-            vec.ends_with(vec)
+            vec.as_slice().ends_with(vec.as_slice())
         })
     }
 
     #[bench]
     fn ends_with_diff_one_element_at_beginning(b: &mut Bencher) {
-        let vec: ~[uint] = slice::from_fn(100, |i| i);
-        let mut match_vec: ~[uint] = slice::from_fn(100, |i| i);
-        match_vec[0] = 200;
+        let vec: Vec<uint> = Vec::from_fn(100, |i| i);
+        let mut match_vec: Vec<uint> = Vec::from_fn(100, |i| i);
+        match_vec.as_mut_slice()[0] = 200;
         b.iter(|| {
-            vec.starts_with(match_vec)
+            vec.as_slice().starts_with(match_vec.as_slice())
         })
     }
 
     #[bench]
     fn contains_last_element(b: &mut Bencher) {
-        let vec: ~[uint] = slice::from_fn(100, |i| i);
+        let vec: Vec<uint> = Vec::from_fn(100, |i| i);
         b.iter(|| {
             vec.contains(&99u)
         })
@@ -4428,14 +3814,14 @@ mod bench {
     #[bench]
     fn zero_1kb_from_elem(b: &mut Bencher) {
         b.iter(|| {
-            let _v: ~[u8] = slice::from_elem(1024, 0u8);
+            Vec::from_elem(1024, 0u8)
         });
     }
 
     #[bench]
     fn zero_1kb_set_memory(b: &mut Bencher) {
         b.iter(|| {
-            let mut v: ~[u8] = slice::with_capacity(1024);
+            let mut v: Vec<uint> = Vec::with_capacity(1024);
             unsafe {
                 let vp = v.as_mut_ptr();
                 ptr::set_memory(vp, 0, 1024);
@@ -4454,15 +3840,13 @@ mod bench {
 
     #[bench]
     fn zero_1kb_loop_set(b: &mut Bencher) {
-        // Slower because the { len, cap, [0 x T] }* repr allows a pointer to the length
-        // field to be aliased (in theory) and prevents LLVM from optimizing loads away.
         b.iter(|| {
-            let mut v: ~[u8] = slice::with_capacity(1024);
+            let mut v: Vec<uint> = Vec::with_capacity(1024);
             unsafe {
                 v.set_len(1024);
             }
             for i in range(0u, 1024) {
-                v[i] = 0;
+                *v.get_mut(i) = 0;
             }
         });
     }
@@ -4470,7 +3854,7 @@ mod bench {
     #[bench]
     fn zero_1kb_mut_iter(b: &mut Bencher) {
         b.iter(|| {
-            let mut v: ~[u8] = slice::with_capacity(1024);
+            let mut v = Vec::with_capacity(1024);
             unsafe {
                 v.set_len(1024);
             }
@@ -4485,7 +3869,7 @@ mod bench {
     fn random_inserts(b: &mut Bencher) {
         let mut rng = weak_rng();
         b.iter(|| {
-                let mut v = slice::from_elem(30, (0u, 0u));
+                let mut v = Vec::from_elem(30, (0u, 0u));
                 for _ in range(0, 100) {
                     let l = v.len();
                     v.insert(rng.gen::<uint>() % (l + 1),
@@ -4497,7 +3881,7 @@ mod bench {
     fn random_removes(b: &mut Bencher) {
         let mut rng = weak_rng();
         b.iter(|| {
-                let mut v = slice::from_elem(130, (0u, 0u));
+                let mut v = Vec::from_elem(130, (0u, 0u));
                 for _ in range(0, 100) {
                     let l = v.len();
                     v.remove(rng.gen::<uint>() % l);
@@ -4537,11 +3921,11 @@ mod bench {
 
     #[bench]
     fn sort_sorted(b: &mut Bencher) {
-        let mut v = slice::from_fn(10000, |i| i);
+        let mut v = Vec::from_fn(10000, |i| i);
         b.iter(|| {
             v.sort();
         });
-        b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
+        b.bytes = (v.len() * mem::size_of_val(v.get(0))) as u64;
     }
 
     type BigSortable = (u64,u64,u64,u64);
@@ -4578,10 +3962,10 @@ mod bench {
 
     #[bench]
     fn sort_big_sorted(b: &mut Bencher) {
-        let mut v = slice::from_fn(10000u, |i| (i, i, i, i));
+        let mut v = Vec::from_fn(10000u, |i| (i, i, i, i));
         b.iter(|| {
             v.sort();
         });
-        b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
+        b.bytes = (v.len() * mem::size_of_val(v.get(0))) as u64;
     }
 }
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 449329ce63a..ed4a8c652f7 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -80,7 +80,7 @@ use char;
 use char::Char;
 use clone::Clone;
 use cmp::{Eq, TotalEq, Ord, TotalOrd, Equiv, Ordering};
-use container::{Container, Mutable};
+use container::Container;
 use fmt;
 use io::Writer;
 use iter::{Iterator, FromIterator, Extendable, range};
@@ -92,7 +92,7 @@ use option::{None, Option, Some};
 use ptr;
 use from_str::FromStr;
 use slice;
-use slice::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector};
+use slice::{OwnedVector, ImmutableVector, MutableVector};
 use slice::{Vector};
 use vec::Vec;
 use default::Default;
@@ -588,7 +588,7 @@ enum NormalizationForm {
 pub struct Normalizations<'a> {
     kind: NormalizationForm,
     iter: Chars<'a>,
-    buffer: ~[(char, u8)],
+    buffer: Vec<(char, u8)>,
     sorted: bool
 }
 
@@ -597,7 +597,7 @@ impl<'a> Iterator<char> for Normalizations<'a> {
     fn next(&mut self) -> Option<char> {
         use unicode::decompose::canonical_combining_class;
 
-        match self.buffer.head() {
+        match self.buffer.as_slice().head() {
             Some(&(c, 0)) => {
                 self.sorted = false;
                 self.buffer.shift();
@@ -622,7 +622,7 @@ impl<'a> Iterator<char> for Normalizations<'a> {
                 decomposer(ch, |d| {
                     let class = canonical_combining_class(d);
                     if class == 0 && !*sorted {
-                        canonical_sort(*buffer);
+                        canonical_sort(buffer.as_mut_slice());
                         *sorted = true;
                     }
                     buffer.push((d, class));
@@ -632,7 +632,7 @@ impl<'a> Iterator<char> for Normalizations<'a> {
         }
 
         if !self.sorted {
-            canonical_sort(self.buffer);
+            canonical_sort(self.buffer.as_mut_slice());
             self.sorted = true;
         }
 
@@ -1336,22 +1336,23 @@ impl<'a> fmt::Show for MaybeOwned<'a> {
 pub mod raw {
     use cast;
     use container::Container;
+    use iter::Iterator;
     use libc;
-    use ptr;
     use ptr::RawPtr;
-    use str::{is_utf8, OwnedStr, StrSlice};
-    use slice;
-    use slice::{MutableVector, ImmutableVector, OwnedVector};
+    use ptr;
     use raw::Slice;
+    use slice::{MutableVector, ImmutableVector, OwnedVector, Vector};
+    use str::{is_utf8, StrSlice};
+    use vec::Vec;
 
     /// Create a Rust string from a *u8 buffer of the given length
     pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str {
-        let mut v: ~[u8] = slice::with_capacity(len);
+        let mut v = Vec::with_capacity(len);
         ptr::copy_memory(v.as_mut_ptr(), buf, len);
         v.set_len(len);
 
-        assert!(is_utf8(v));
-        ::cast::transmute(v)
+        assert!(is_utf8(v.as_slice()));
+        ::cast::transmute(v.move_iter().collect::<~[u8]>())
     }
 
     #[lang="strdup_uniq"]
@@ -1594,16 +1595,6 @@ impl Container for ~str {
     fn len(&self) -> uint { self.as_slice().len() }
 }
 
-impl Mutable for ~str {
-    /// Remove all content, make the string empty
-    #[inline]
-    fn clear(&mut self) {
-        unsafe {
-            self.set_len(0)
-        }
-    }
-}
-
 /// Methods for string slices
 pub trait StrSlice<'a> {
     /// Returns true if one string contains another
@@ -2396,7 +2387,7 @@ impl<'a> StrSlice<'a> for &'a str {
     fn nfd_chars(&self) -> Normalizations<'a> {
         Normalizations {
             iter: self.chars(),
-            buffer: ~[],
+            buffer: Vec::new(),
             sorted: false,
             kind: NFD
         }
@@ -2406,7 +2397,7 @@ impl<'a> StrSlice<'a> for &'a str {
     fn nfkd_chars(&self) -> Normalizations<'a> {
         Normalizations {
             iter: self.chars(),
-            buffer: ~[],
+            buffer: Vec::new(),
             sorted: false,
             kind: NFKD
         }
@@ -2544,22 +2535,22 @@ impl<'a> StrSlice<'a> for &'a str {
     fn to_owned(&self) -> ~str {
         let len = self.len();
         unsafe {
-            let mut v = slice::with_capacity(len);
+            let mut v = Vec::with_capacity(len);
 
             ptr::copy_memory(v.as_mut_ptr(), self.as_ptr(), len);
             v.set_len(len);
-            ::cast::transmute(v)
+            ::cast::transmute(v.move_iter().collect::<~[u8]>())
         }
     }
 
     fn to_utf16(&self) -> ~[u16] {
-        let mut u = ~[];
+        let mut u = Vec::new();;
         for ch in self.chars() {
             let mut buf = [0u16, ..2];
             let n = ch.encode_utf16(buf /* as mut slice! */);
             u.push_all(buf.slice_to(n));
         }
-        u
+        u.move_iter().collect()
     }
 
     #[inline]
@@ -2694,29 +2685,30 @@ impl<'a> StrSlice<'a> for &'a str {
         if slen == 0 { return tlen; }
         if tlen == 0 { return slen; }
 
-        let mut dcol = slice::from_fn(tlen + 1, |x| x);
+        let mut dcol = Vec::from_fn(tlen + 1, |x| x);
 
         for (i, sc) in self.chars().enumerate() {
 
             let mut current = i;
-            dcol[0] = current + 1;
+            *dcol.get_mut(0) = current + 1;
 
             for (j, tc) in t.chars().enumerate() {
 
-                let next = dcol[j + 1];
+                let next = *dcol.get(j + 1);
 
                 if sc == tc {
-                    dcol[j + 1] = current;
+                    *dcol.get_mut(j + 1) = current;
                 } else {
-                    dcol[j + 1] = ::cmp::min(current, next);
-                    dcol[j + 1] = ::cmp::min(dcol[j + 1], dcol[j]) + 1;
+                    *dcol.get_mut(j + 1) = ::cmp::min(current, next);
+                    *dcol.get_mut(j + 1) = ::cmp::min(*dcol.get(j + 1),
+                                                      *dcol.get(j)) + 1;
                 }
 
                 current = next;
             }
         }
 
-        return dcol[tlen];
+        return *dcol.get(tlen);
     }
 
     fn subslice_offset(&self, inner: &str) -> uint {
@@ -2738,44 +2730,22 @@ impl<'a> StrSlice<'a> for &'a str {
 
 /// Methods for owned strings
 pub trait OwnedStr {
-    /// Shorten a string to the specified length (which must be <= the current length)
-    fn truncate(&mut self, len: uint);
-
     /// Consumes the string, returning the underlying byte buffer.
     ///
     /// The buffer does not have a null terminator.
     fn into_bytes(self) -> ~[u8];
 
-    /// Sets the length of a string
-    ///
-    /// This will explicitly set the size of the string, without actually
-    /// modifying its buffers, so it is up to the caller to ensure that
-    /// the string is actually the specified size.
-    unsafe fn set_len(&mut self, new_len: uint);
-
     /// Pushes the given string onto this string, returning the concatenation of the two strings.
     fn append(self, rhs: &str) -> ~str;
 }
 
 impl OwnedStr for ~str {
     #[inline]
-    fn truncate(&mut self, len: uint) {
-        assert!(len <= self.len());
-        assert!(self.is_char_boundary(len));
-        unsafe { self.set_len(len); }
-    }
-
-    #[inline]
     fn into_bytes(self) -> ~[u8] {
         unsafe { cast::transmute(self) }
     }
 
     #[inline]
-    unsafe fn set_len(&mut self, new_len: uint) {
-        raw::as_owned_vec(self).set_len(new_len)
-    }
-
-    #[inline]
     fn append(self, rhs: &str) -> ~str {
         let mut new_str = StrBuf::from_owned_str(self);
         new_str.push_str(rhs);
@@ -3409,8 +3379,7 @@ mod tests {
         assert_eq!(a.subslice_offset(c), 0);
 
         let string = "a\nb\nc";
-        let mut lines = ~[];
-        for line in string.lines() { lines.push(line) }
+        let lines: ~[&str] = string.lines().collect();
         assert_eq!(string.subslice_offset(lines[0]), 0);
         assert_eq!(string.subslice_offset(lines[1]), 2);
         assert_eq!(string.subslice_offset(lines[2]), 4);
@@ -4259,9 +4228,9 @@ mod bench {
 
     #[bench]
     fn from_utf8_lossy_100_invalid(b: &mut Bencher) {
-        let s = ::slice::from_elem(100, 0xF5u8);
+        let s = Vec::from_elem(100, 0xF5u8);
         b.iter(|| {
-            let _ = from_utf8_lossy(s);
+            let _ = from_utf8_lossy(s.as_slice());
         });
     }
 
diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs
index 0d0bd740e41..498a6252a8f 100644
--- a/src/libstd/sync/arc.rs
+++ b/src/libstd/sync/arc.rs
@@ -23,12 +23,13 @@
 
 use cast;
 use clone::Clone;
+use iter::Iterator;
 use kinds::Send;
 use ops::Drop;
 use ptr::RawPtr;
 use sync::atomics::{fence, AtomicUint, Relaxed, Acquire, Release};
-use slice;
 use ty::Unsafe;
+use vec::Vec;
 
 /// An atomically reference counted pointer.
 ///
@@ -73,7 +74,8 @@ impl<T: Send> UnsafeArc<T> {
                 ~[] // need to free data here
             } else {
                 let ptr = new_inner(data, num_handles);
-                slice::from_fn(num_handles, |_| UnsafeArc { data: ptr })
+                let v = Vec::from_fn(num_handles, |_| UnsafeArc { data: ptr });
+                v.move_iter().collect()
             }
         }
     }
diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs
index 8beadce2160..97239707d32 100644
--- a/src/libstd/sync/deque.rs
+++ b/src/libstd/sync/deque.rs
@@ -61,7 +61,7 @@ use ptr::RawPtr;
 use sync::arc::UnsafeArc;
 use sync::atomics::{AtomicInt, AtomicPtr, SeqCst};
 use unstable::sync::Exclusive;
-use slice::{OwnedVector, ImmutableVector};
+use slice::ImmutableVector;
 use vec::Vec;
 
 // Once the queue is less than 1/K full, then it will be downsized. Note that
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs
index f1dd7aa150b..b7f6d730d12 100644
--- a/src/libstd/unstable/sync.rs
+++ b/src/libstd/unstable/sync.rs
@@ -115,7 +115,7 @@ mod tests {
     #[test]
     fn exclusive_new_arc() {
         unsafe {
-            let mut futures = ~[];
+            let mut futures = Vec::new();
 
             let num_tasks = 10;
             let count = 10;
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 96cbac8869e..5480805478c 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -614,13 +614,9 @@ impl<T> Vec<T> {
     /// ```
     #[inline]
     pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
-        // See the comment in as_slice() for what's going on here.
-        let slice = if mem::size_of::<T>() == 0 {
-            Slice { data: 1 as *T, len: self.len }
-        } else {
-            Slice { data: self.ptr as *T, len: self.len }
-        };
-        unsafe { transmute(slice) }
+        unsafe {
+            transmute(Slice { data: self.as_mut_ptr() as *T, len: self.len })
+        }
     }
 
     /// Creates a consuming iterator, that is, one that moves each
@@ -1143,7 +1139,15 @@ impl<T> Vec<T> {
     /// would also make any pointers to it invalid.
     #[inline]
     pub fn as_ptr(&self) -> *T {
-        self.as_slice().as_ptr()
+        // If we have a 0-sized vector, then the base pointer should not be NULL
+        // because an iterator over the slice will attempt to yield the base
+        // pointer as the first element in the vector, but this will end up
+        // being Some(NULL) which is optimized to None.
+        if mem::size_of::<T>() == 0 {
+            1 as *T
+        } else {
+            self.ptr as *T
+        }
     }
 
     /// Returns a mutable unsafe pointer to the vector's buffer.
@@ -1155,7 +1159,12 @@ impl<T> Vec<T> {
     /// would also make any pointers to it invalid.
     #[inline]
     pub fn as_mut_ptr(&mut self) -> *mut T {
-        self.as_mut_slice().as_mut_ptr()
+        // see above for the 0-size check
+        if mem::size_of::<T>() == 0 {
+            1 as *mut T
+        } else {
+            self.ptr
+        }
     }
 
     /// Retains only the elements specified by the predicate.
@@ -1356,16 +1365,7 @@ impl<T> Vector<T> for Vec<T> {
     /// ```
     #[inline]
     fn as_slice<'a>(&'a self) -> &'a [T] {
-        // If we have a 0-sized vector, then the base pointer should not be NULL
-        // because an iterator over the slice will attempt to yield the base
-        // pointer as the first element in the vector, but this will end up
-        // being Some(NULL) which is optimized to None.
-        let slice = if mem::size_of::<T>() == 0 {
-            Slice { data: 1 as *T, len: self.len }
-        } else {
-            Slice { data: self.ptr as *T, len: self.len }
-        };
-        unsafe { transmute(slice) }
+        unsafe { transmute(Slice { data: self.as_ptr(), len: self.len }) }
     }
 }