Why can't move element of Vector?

You can't do a move using an indexing op because they are defined using references. Rust is notably missing a move reference, so you can't use an indexing op to move out of a vector.

You can do vec.remove(0) to take something out of a vector, or if you are removing from the end you can do vec.pop().

1 Like