Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upIterator over entries of Hash* #33549
Comments
nagisa
added
the
A-collections
label
May 10, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@eefriedman Consider following code which could potentially be a poor-man’s implementation of pop: for entry in map.entries() {
if let Entry::Occupied(o) = entry {
return o.remove();
} else { unreachable!() }
}That cannot be implemented with iter_mut() today. |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure that the current |
steveklabnik
added
the
A-libs
label
Aug 4, 2016
steveklabnik
added
T-libs
and removed
A-libs
labels
Mar 24, 2017
Mark-Simulacrum
added
the
C-feature-request
label
Jul 25, 2017
This comment has been minimized.
This comment has been minimized.
|
I agree with @apasel422 that I don't think this will work with an iterator of entries. The Iterator trait permits the caller to hold on to multiple items at the same time, which in this case would mean multiple items that each have mutable access to the same HashMap. I think the use case of iterating over key-value pairs and conditionally removing them efficiently is addressed by |
nagisa commentedMay 10, 2016
An iterator over entries of HashMap/Set could be added?