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

Allow indexing HashMap/BTreeMap mutably #25034

Closed
Ms2ger opened this issue May 1, 2015 · 5 comments
Closed

Allow indexing HashMap/BTreeMap mutably #25034

Ms2ger opened this issue May 1, 2015 · 5 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented May 1, 2015

Note #23559. The suggestion is to use get_mut instead, but that's a lot uglier.

@Gankra
Copy link
Contributor

Gankra commented May 1, 2015

tl;dr for anyone frustrated with this: blocked on IndexSet being fully defined to avoid Messes

@steveklabnik
Copy link
Member

Triage: no change.

@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 22, 2017
@Mark-Simulacrum Mark-Simulacrum changed the title Allow indexing HashMap mutably Allow indexing HashMap/BTreeMap mutably Jul 24, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 17, 2017

This is going to require an RFC. Let's track this as part of rust-lang/rfcs#997.

@dtolnay dtolnay closed this as completed Nov 17, 2017
@BatmanAoD
Copy link
Member

@dtolnay @Gankra It's not immediately clear to me from looking at RFC issue 997 why BTreeMap and HashMap can't yet implement the existing IndexMut trait; is there already discussion about the connection somewhere that you can point me to? If not, would one of you mind explaining the connection here?

@dtolnay
Copy link
Member

dtolnay commented Jan 23, 2020

IndexMut would make map[k] = v compile but panic on key not already present. Presumably a user would expect insertion into the map, like in C++ and Go and JavaScript and every other language with that syntax, not a panic. That is rust-lang/rfcs#997 and some designs are mutually exclusive with IndexMut.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants