diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 8b07b21c578..9548805c1f8 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -29,6 +29,16 @@ enum SmallVectorRepr<T> { Many(Vec<T>), } +impl<T> Into<Vec<T>> for SmallVector<T> { + fn into(self) -> Vec<T> { + match self.repr { + Zero => Vec::new(), + One(t) => vec![t], + Many(vec) => vec, + } + } +} + impl<T> FromIterator<T> for SmallVector<T> { fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> SmallVector<T> { let mut v = SmallVector::zero(); |
