Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create indexmap/set in static contexts #202

Closed
mwillsey opened this issue Sep 16, 2021 · 3 comments · Fixed by #203
Closed

Create indexmap/set in static contexts #202

mwillsey opened this issue Sep 16, 2021 · 3 comments · Fixed by #203

Comments

@mwillsey
Copy link
Contributor

Would it be possible to add a new-like function that is const? It would be useful to create static maps without the aid of something like once_cell.

From scanning the code, it seems like with_hasher is maybe the right function to make const, since you don't have to make a hasher (it's given) and "no allocation" is already in the spec for that function.

@cuviper
Copy link
Member

cuviper commented Sep 16, 2021

Since we now have const Vec::new and RawTable::new as well, yes I think this should be possible.

@mwillsey
Copy link
Contributor Author

Happy to make a PR. Do you think with_hasher is the right target? Any others?

@cuviper
Copy link
Member

cuviper commented Sep 16, 2021

A PR is welcome! I think with_hasher is the only constructor we can support. For precedent, the standard HashMap doesn't have any constant functions, but hashbrown does have constant with_hasher in its own map and set.

For other methods, Vec and/or RawTable don't give us anything else to work with, not even len.

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 a pull request may close this issue.

2 participants