I'm trying to remove an element from a vec with the new remove_item method.
To do so, I loop through the vec to obtain the reference I'm searching for and I then use it to call remove_item.
Sadly, I can't make it work.
This way of working is inherently incompatible with Rust, because you're holding on to a read-only reference that "freezes" the object it belongs to for as long as the reference exists. Don't think of references as pointers to elements, but as read/write locks on data.
It's also inefficient, because remove_item searches again.
You can use .iter().enumerate() and remember the index to remove. This will enable most efficient removal, and the index will go under the radar of the borrow checker.
If you were combining this with other iterators or .collect(), use .filter() instead.