Implement Into<Vec<T>> for SmallVector<T>

This commit is contained in:
Jeffrey Seyfried 2016-06-12 01:49:58 +00:00
parent 8104df27ec
commit 3b8e1f309e

View File

@ -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();