-
Notifications
You must be signed in to change notification settings - Fork 11
Description
We currently cannot implement a generic insertion ordered drain iterator for ListOrderedMultimap due to the constraint that keys must remain in the map until all values have been drained. The pop_back and pop_front are workarounds for this limitation by providing KeyWrappers instead of moving the key out of the map.
A similar KeyWrapper approach cannot be done with an actual iterator due to lifetime limitations (i.e. it's not safe to call next while the previous items yielded have yet to have been dropped, this cannot be enforced through the iterator trait). But if we add the constraint that the Key type is Copy or potentially Clone, we can add a drain iterator and just copy/clone the keys when iterating. Doing it with Clone seems like a bit too much as it can potentially have a massive performance impact, but perhaps this should just be the user's responsibility.