You can use Vec
‘s extend
method. extend
takes a value of any type that implements IntoIterator
(which includes all iterator types) and extends the Vec
by all elements returned from the iterator:
vector.extend(it)
Since extend
belongs to the Extend
trait, it also works for many other collection types.