Iterators produce a series of values, and we can call the collect
method on an iterator to turn it into a collection, such as a vector, that contains all the elements the iterator produces.
We can use the
collect
function to create many kinds of collections, so we explicitly annotate the type ofargs
to specify that we want a vector of strings. Although we very rarely need to annotate types in Rust,collect
is one function you do often need to annotate because Rust isnβt able to infer the kind of collection you want.