about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-04-22 13:11:36 -0700
committerbors <bors@rust-lang.org>2014-04-22 13:11:36 -0700
commit16a5b3127a97424108180a79dcd4cd53a5646e24 (patch)
tree7ab522780bc733dbd3eb08034841e96be0ef5136 /src/libsyntax
parent6c82eb5d4de012ccf38620f81d8655308d37e318 (diff)
parent70f3409875be7c2d0f9d48092eb98f11ee734378 (diff)
downloadrust-16a5b3127a97424108180a79dcd4cd53a5646e24.tar.gz
rust-16a5b3127a97424108180a79dcd4cd53a5646e24.zip
auto merge of #13670 : eddyb/rust/more-de-at, r=pcwalton
Diffstat (limited to 'src/libsyntax')
-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),