Some of the most useful generic types are collection types. A vector is a variably sized list of items
represented by the struct Vec
.
The macro vec!
lets us easily create a vector rather than manually constructing one.
Vec
has the method iter()
which creates an iterator from a vector, allowing us to easily
put a vector into a for
loop.
Memory Details:
Vec
is a struct, but internally it contains a reference to a fixed list of its items on the heap.