LPGhatguy / thunderdome

Arena type inspired by generational-arena
Apache License 2.0
197 stars 15 forks source link

Add Arena::map #9

Open Ratysz opened 3 years ago

Ratysz commented 3 years ago

Analogous to Iterator::map(), array ::map(), etc...

My usecase is pretty much typestate pattern; I want to shed parts of stored items that aren't useful anymore, but I also want existing indices to remain valid.

Alternative approach is to allow constructing Arena<T> from iterator of (Index, T). This could also help with implementing serialization further down the line.

LPGhatguy commented 3 years ago

We talked about this with @sdleffler on Discord a little bit. I think this functionality is useful, but I'd like to explore the option of being able to collect from an iterator of (Index, T) before we decide either way. If that approach has no obvious downsides, it seems preferable to me.

Ratysz commented 3 years ago

Sounds fine by me; in fact, I would prefer that as well, as it's strictly more versatile. Don't hesitate to close this whenever, should you settle on that approach.