about summary refs log tree commit diff
path: root/src/libsyntax/util
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-06-16 06:44:53 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-06-16 07:58:43 +0000
commitc41cf30e9d0a5ae47e944fd8ee27eda9ce815ee1 (patch)
tree68c843f906df68211f11e624a5effc5fdb57cbf2 /src/libsyntax/util
parent83d283b67bbc668e1ab262b3f199c046567e9954 (diff)
downloadrust-c41cf30e9d0a5ae47e944fd8ee27eda9ce815ee1.tar.gz
rust-c41cf30e9d0a5ae47e944fd8ee27eda9ce815ee1.zip
Strip unconfigured nodes from decorator-generated AST
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 8b07b21c578..78395462fb5 100644
--- a/src/libsyntax/util/small_vector.rs
+++ b/src/libsyntax/util/small_vector.rs
@@ -136,6 +136,15 @@ impl<T> SmallVector<T> {
     }
 
     pub fn is_empty(&self) -> bool { self.len() == 0 }
+
+    pub fn map<U, F: FnMut(T) -> U>(self, mut f: F) -> SmallVector<U> {
+        let repr = match self.repr {
+            Zero => Zero,
+            One(t) => One(f(t)),
+            Many(vec) => Many(vec.into_iter().map(f).collect()),
+        };
+        SmallVector { repr: repr }
+    }
 }
 
 impl<T> IntoIterator for SmallVector<T> {