rust-lang / rust-lang/hashbrown
Does iter_mut() guarentee stable order if you don't insert/remove elements?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3k
- Forks
- 358
- Avg merge
- 11h 57m
- Merged PRs (30d)
- 2
Description
https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.iter_mut
An iterator visiting all key-value pairs in arbitrary order, with mutable references to the values. The iterator element type is (&'a K, &'a mut V).
Question on the docs here, if you don't insert/remove elements from the hashmap at all and just do:
hashmap.iter_mut();
hashmap.get_mut() += 1; // updating existing values doesn't mutate the hashmap itself vs insertion/removal
hashmap.iter_mut(); //again a few lines down without mutation
Is iteration guaranteed to be stable or can that change one day? I realize I rely on this order being the same. I'm guessing no since there is no test and doc for it so it should not be relied on?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the HashMap::iter_mut documentation linked in the issue, then compare it with HashMap::get_mut and the surrounding implementation behavior. Determine whether stable iteration order without insertion or removal is an intended guarantee; done means the documentation clearly states the supported behavior and any relevant test or maintainer decision is captured.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100