Rollup merge of #130290 - passcod:stabilise-entry-insert, r=ChrisDenton

Stabilize entry_insert

This stabilises `HashMap::Entry::insert_entry`, following the FCP in tracking issue #65225.

This was implemented in #64656 five years ago.
This commit is contained in:
León Orell Valerian Liehr 2024-09-14 18:12:12 +02:00 committed by GitHub
commit f873367243
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2754,7 +2754,6 @@ pub fn and_modify<F>(self, f: F) -> Self
/// # Examples
///
/// ```
/// #![feature(entry_insert)]
/// use std::collections::HashMap;
///
/// let mut map: HashMap<&str, String> = HashMap::new();
@ -2763,7 +2762,7 @@ pub fn and_modify<F>(self, f: F) -> Self
/// assert_eq!(entry.key(), &"poneyland");
/// ```
#[inline]
#[unstable(feature = "entry_insert", issue = "65225")]
#[stable(feature = "entry_insert", since = "CURRENT_RUSTC_VERSION")]
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
match self {
Occupied(mut entry) => {
@ -3097,7 +3096,6 @@ pub fn insert(self, value: V) -> &'a mut V {
/// # Examples
///
/// ```
/// #![feature(entry_insert)]
/// use std::collections::HashMap;
/// use std::collections::hash_map::Entry;
///
@ -3109,7 +3107,7 @@ pub fn insert(self, value: V) -> &'a mut V {
/// assert_eq!(map["poneyland"], 37);
/// ```
#[inline]
#[unstable(feature = "entry_insert", issue = "65225")]
#[stable(feature = "entry_insert", since = "CURRENT_RUSTC_VERSION")]
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
let base = self.base.insert_entry(value);
OccupiedEntry { base }