Allow collecting an iterator of T to Punctuated<T, P>
diff --git a/src/punctuated.rs b/src/punctuated.rs
index 38363b6..e1e9541 100644
--- a/src/punctuated.rs
+++ b/src/punctuated.rs
@@ -220,6 +220,28 @@
}
}
+impl<T, P> FromIterator<T> for Punctuated<T, P>
+where
+ P: Default,
+{
+ fn from_iter<I: IntoIterator<Item = T>>(i: I) -> Self {
+ let mut ret = Punctuated::new();
+ ret.extend(i);
+ ret
+ }
+}
+
+impl<T, P> Extend<T> for Punctuated<T, P>
+where
+ P: Default,
+{
+ fn extend<I: IntoIterator<Item = T>>(&mut self, i: I) {
+ for value in i {
+ self.push(value);
+ }
+ }
+}
+
impl<T, P> FromIterator<Pair<T, P>> for Punctuated<T, P> {
fn from_iter<I: IntoIterator<Item = Pair<T, P>>>(i: I) -> Self {
let mut ret = Punctuated::new();