Skip to content

Add hash_set::OccupiedEntry::into_ref() - #757

Merged
clarfonthey merged 1 commit into
rust-lang:mainfrom
MikkelPaulson:add-hash-set-occupied-entry-into-ref
Oct 30, 2026
Merged

clarfonthey merged 1 commit into
rust-lang:mainfrom
MikkelPaulson:add-hash-set-occupied-entry-into-ref

Conversation

@MikkelPaulson

Copy link
Copy Markdown
Contributor

hash_map::OccupiedEntry provides into_entry and into_mut to consume the entry and return references to the map, but there was no way to do the same for a HashSet.

New methods:

  • fn set::OccupiedEntry::into_ref(self) -> &'a V;

Also added some rudimentary coverage for the HashSet entry API.

(Second try at #756.)

`hash_map::OccupiedEntry` provides `into_entry` and `into_mut` to
consume the entry and return references to the map, but there was no way
to do the same for a `HashSet`.

New methods:

* `fn set::OccupiedEntry::into_ref(self) -> &'a V;`

Also added some rudimentary coverage for the `HashSet` entry API.
@clarfonthey

Copy link
Copy Markdown
Contributor

So, why exact is this useful, when it's equivalent to into_mut? You can always demote mutable references into immutable ones.

@MikkelPaulson

MikkelPaulson commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@clarfonthey This is on HashSet, not HashMap. No mutable references here. (I recognize that the first word in the description is hash_map, so I understand the confusion.)

@clarfonthey

Copy link
Copy Markdown
Contributor

…you're right, that makes a load of sense. This is fine, then.

@clarfonthey
clarfonthey added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 30, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor

(CI failure is #758.)

@clarfonthey
clarfonthey added this pull request to the merge queue Oct 30, 2026
@clarfonthey
clarfonthey removed this pull request from the merge queue due to a manual request Oct 30, 2026
@clarfonthey
clarfonthey added this pull request to the merge queue Oct 30, 2026
Merged via the queue into rust-lang:main with commit 5b92ed0 Oct 30, 2026
26 checks passed
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 this pull request may close these issues.

2 participants