Skip to content

Consider drain iterator for Copy/Clone types #2

@sgodwincs

Description

@sgodwincs

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions