It seems I don’t know how to read Rust’s documentation. I tried to write code like this:
let v = vec![String::from("one"), String::from("two")]; let first = v;
This doesn’t compile because let first = v tries to move the String out of v. So I was looking at the Vec documentation but all I can find is a mention of the Index trait, which has this method:
fn index(&self, index: Idx) -> &Self::Output
So it returns a reference. But what is it that’s being referenced here and how can this possibly result in an attempt move anything?
I know that I can access the Vec element as &v to avoid a move. But why do I have to do that given what the documentation says?