diff options
Diffstat (limited to 'src/libsyntax/util/small_vector.rs')
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 9548805c1f8..893646f121f 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -146,6 +146,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> { |
