about summary refs log tree commit diff
path: root/src/libsyntax/util
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2014-04-22 02:21:52 +0300
committerEduard Burtescu <edy.burt@gmail.com>2014-04-22 19:20:12 +0300
commit57aa0eb0aa0f4fc502ef8b1d3543cb02c2092932 (patch)
treea1eff06ec72c235670d58e1008ec878375752cfe /src/libsyntax/util
parent1e5a112922fbac2a6f2d0aa9e6eb90bc3a4422a5 (diff)
downloadrust-57aa0eb0aa0f4fc502ef8b1d3543cb02c2092932.tar.gz
rust-57aa0eb0aa0f4fc502ef8b1d3543cb02c2092932.zip
rustc: de-@ middle::ty.
Diffstat (limited to 'src/libsyntax/util')
-rw-r--r--src/libsyntax/util/small_vector.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs
index 792673e3298..693407b854f 100644
--- a/src/libsyntax/util/small_vector.rs
+++ b/src/libsyntax/util/small_vector.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use std::mem;
+use std::slice;
 use std::vec;
 
 /// A vector type optimized for cases where the size is almost always 0 or 1
@@ -61,6 +62,14 @@ impl<T> SmallVector<T> {
         SmallVector { repr: Many(vs) }
     }
 
+    pub fn as_slice<'a>(&'a self) -> &'a [T] {
+        match self.repr {
+            Zero => &[],
+            One(ref v) => slice::ref_slice(v),
+            Many(ref vs) => vs.as_slice()
+        }
+    }
+
     pub fn push(&mut self, v: T) {
         match self.repr {
             Zero => self.repr = One(v),