I found out that the Vec::retain method is way better to use than a bunch of Vec::remove when you need to potentially remove more than one element in one roll.
Changing the function signature (the argument of the retain method) is a breaking change. I tried to change it in the std, and BinaryHeap wasn't happy about that. So I would like your advice, is it better to create a new Vec::retain_mut or just let users implement their own function to do that?
// implemented on Vec<T>
fn retain_mut<F>(&mut self, mut f: F) where F: FnMut(&mut T) -> bool;
While retain_mut sounds ok to me, there's also drain_filter that does give you &mut T, and you can just drop/ignore the returned iterator to discard those items.
There's some difference in panic behavior though, since draining has to deal with the fact that some of the items may have been moved out. Retain just ends up with shuffled items if you panic, which is still safe. If you never panic, then drain_filter/retain_mut semantics would be the same, but with possibly pessimized performance in drain for those checks.