I want to iterate over a collection type in a struct and remove some values, but Rust prevents me from destroying the collection:
fn some_method(&mut self) {
self.collection = self
.collection
.into_iter()
.filter(/* ... */
.collect();
}
I could clone all of the values to build another collection, but that's not efficient. What's the idiomatic way of removing a value from the collection in place in Rust?