From 57aa0eb0aa0f4fc502ef8b1d3543cb02c2092932 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 22 Apr 2014 02:21:52 +0300 Subject: rustc: de-@ middle::ty. --- src/libsyntax/util/small_vector.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libsyntax') 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 SmallVector { 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), -- cgit 1.4.1-3-g733a5