Skip to content

Commit

Permalink
Rollup merge of rust-lang#130290 - passcod:stabilise-entry-insert, r=…
Browse files Browse the repository at this point in the history
…ChrisDenton

Stabilize entry_insert

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

This was implemented in rust-lang#64656 five years ago.
  • Loading branch information
fmease authored Sep 14, 2024
2 parents a9dcd7f + 0b2235d commit f873367
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2754,7 +2754,6 @@ impl<'a, K, V> Entry<'a, K, V> {
/// # Examples
///
/// ```
/// #![feature(entry_insert)]
/// use std::collections::HashMap;
///
/// let mut map: HashMap<&str, String> = HashMap::new();
Expand All @@ -2763,7 +2762,7 @@ impl<'a, K, V> Entry<'a, K, V> {
/// 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) => {
Expand Down Expand Up @@ -3097,7 +3096,6 @@ impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
/// # Examples
///
/// ```
/// #![feature(entry_insert)]
/// use std::collections::HashMap;
/// use std::collections::hash_map::Entry;
///
Expand All @@ -3109,7 +3107,7 @@ impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, 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 }
Expand Down

0 comments on commit f873367

Please sign in to comment.