From c41cf30e9d0a5ae47e944fd8ee27eda9ce815ee1 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Thu, 16 Jun 2016 06:44:53 +0000 Subject: Strip unconfigured nodes from decorator-generated AST --- src/libsyntax/util/small_vector.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libsyntax/util') 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 SmallVector { } pub fn is_empty(&self) -> bool { self.len() == 0 } + + pub fn map U>(self, mut f: F) -> SmallVector { + 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 IntoIterator for SmallVector { -- cgit 1.4.1-3-g733a5