How can I push an iterator to an existing vector (or any other collection)?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)