Skip to content

Add Arena::map - #9

Open
Ratysz wants to merge 1 commit into
LPGhatguy:mainfrom
Ratysz:main
Open

Add Arena::map#9
Ratysz wants to merge 1 commit into
LPGhatguy:mainfrom
Ratysz:main

Conversation

@Ratysz

@Ratysz Ratysz commented Oct 19, 2020

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Owner

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

Ratysz commented Nov 4, 2020

Copy link
Copy Markdown
Author

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.

@LPGhatguy

Copy link
Copy Markdown
Owner

Hi, I wanted to post an updated comment on this.

Years later, I still think we should not have Arena::map (because other allocating data structures like Vec don't) but we should definitely implement FromIterator like I alluded to years ago. I would accept a PR from anyone interested to do that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants