Borrow checker Advanced
26 Moving out
You can't move a value out from behind a reference -- that would leave a hole. The fix is to swap something valid into its place and hand back the old value. std gives you take for exactly this.
Fix take_at: return the String at index i, leaving an empty String behind. You can't move out of a Vec by indexing.
Hints
std::mem::take(&mut v[i])swaps inString::default()(empty) and returns the old value.
Reveal solution
fn take_at(v: &mut Vec<String>, i: usize) -> String {
std::mem::take(&mut v[i])
}