-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
(Originally filed as rust-lang/rust#37986, but a pre-RFC belongs in the RFC repo, not the rust repo. Re-filing it here.)
I'd like to have a pop()
method available for HashSet
, which removes an item from the set if any, and returns an Option<T>
(returning None
if empty). That would make it easy to iterate over a set with while let element = set.pop() { ... }
, without holding a mutable reference to the set as HashSet::drain()
does, so you can insert more items into the set as you iterate.
Does that seem like a reasonable method to add to HashSet? Does this need an RFC, or just a patch to std?
burdges, malbarbo, birkenfeld, clarfonthey, cipriancraciun and 17 more
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.