about summary refs log tree commit diff
path: root/src/libsyntax/opt_vec.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/opt_vec.rs')
-rw-r--r--src/libsyntax/opt_vec.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs
index 325df0ba777..ec81fff51c7 100644
--- a/src/libsyntax/opt_vec.rs
+++ b/src/libsyntax/opt_vec.rs
@@ -15,20 +15,21 @@
  * other useful things like `push()` and `len()`.
  */
 
-use std::vec;
 use std::default::Default;
+use std::vec;
+use std::vec_ng::Vec;
 
 #[deriving(Clone, Encodable, Decodable, Hash)]
 pub enum OptVec<T> {
     Empty,
-    Vec(~[T])
+    Vec(Vec<T> )
 }
 
 pub fn with<T>(t: T) -> OptVec<T> {
-    Vec(~[t])
+    Vec(vec!(t))
 }
 
-pub fn from<T>(t: ~[T]) -> OptVec<T> {
+pub fn from<T>(t: Vec<T> ) -> OptVec<T> {
     if t.len() == 0 {
         Empty
     } else {
@@ -44,7 +45,7 @@ impl<T> OptVec<T> {
                 return;
             }
             Empty => {
-                *self = Vec(~[t]);
+                *self = Vec(vec!(t));
             }
         }
     }
@@ -87,7 +88,7 @@ impl<T> OptVec<T> {
     pub fn get<'a>(&'a self, i: uint) -> &'a T {
         match *self {
             Empty => fail!("invalid index {}", i),
-            Vec(ref v) => &v[i]
+            Vec(ref v) => v.get(i)
         }
     }
 
@@ -121,11 +122,11 @@ impl<T> OptVec<T> {
     }
 
     #[inline]
-    pub fn map_to_vec<B>(&self, op: |&T| -> B) -> ~[B] {
+    pub fn map_to_vec<B>(&self, op: |&T| -> B) -> Vec<B> {
         self.iter().map(op).collect()
     }
 
-    pub fn mapi_to_vec<B>(&self, op: |uint, &T| -> B) -> ~[B] {
+    pub fn mapi_to_vec<B>(&self, op: |uint, &T| -> B) -> Vec<B> {
         let mut index = 0;
         self.map_to_vec(|a| {
             let i = index;
@@ -135,19 +136,19 @@ impl<T> OptVec<T> {
     }
 }
 
-pub fn take_vec<T>(v: OptVec<T>) -> ~[T] {
+pub fn take_vec<T>(v: OptVec<T>) -> Vec<T> {
     match v {
-        Empty => ~[],
+        Empty => Vec::new(),
         Vec(v) => v
     }
 }
 
 impl<T:Clone> OptVec<T> {
     pub fn prepend(&self, t: T) -> OptVec<T> {
-        let mut v0 = ~[t];
+        let mut v0 = vec!(t);
         match *self {
             Empty => {}
-            Vec(ref v1) => { v0.push_all(*v1); }
+            Vec(ref v1) => { v0.push_all(v1.as_slice()); }
         }
         return Vec(v0);
     }