You
I cannot mutate a vector while iterating over it.
ChatGPT
That is the rule doing its job: a resize would invalidate the iterator. Collect the changes and apply after, or iterate by index, or use retain when you are removing:
items.retain(|item| item.keep);
In C++ the same code compiles and reads freed memory occasionally, which is the difference being paid for.
