Example:
let mut protagonist = Vec::new();
for (_i, _c) in challenger.chars().enumerate() {
protagonist.push('_');
}
let s = String::from_iter(protagonist);
protagonist.push('t'); // error: value borrowed here after move
I know that in order to solve it you have to write &protagonist instead when passing it to the from_iter() function. As in pass by reference, instead of value. But my question is why does the object move away in the first place when you pass by value and you can no longer use it anymore in your main function? What purpose does this serve?