How safe are swift collections when used with invalidated iterators / indices?
问题 I'm not seeing a lot of info in the swift stdlib reference. For example, Dictionary says certain methods (like remove) will invalidate indices, but that's it. For a language to call itself "safe", it needs a solution to the classic C++ footguns: get pointer to element in a vector, then add more elements (pointer is now invalidated), now use pointer, crash start iterating through a collection. while iterating, remove some elements (either before or after the current iterator position).