Skip to content

Commit 3009dd7

Browse files
authored
Rollup merge of #90345 - passcod:entry-insert, r=dtolnay
Stabilise entry_insert This stabilises `HashMap:Entry::insert_entry` etc. Tracking issue #65225. It will need an FCP. This was implemented in #64656 two years ago. This PR includes the rename and change discussed in #65225 (comment), happy to split if needed.
2 parents 46171fa + a2fd84a commit 3009dd7

File tree

1 file changed

+6
-6
lines changed
  • library/std/src/collections/hash

1 file changed

+6
-6
lines changed

library/std/src/collections/hash/map.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2462,17 +2462,16 @@ impl<'a, K, V> Entry<'a, K, V> {
24622462
/// # Examples
24632463
///
24642464
/// ```
2465-
/// #![feature(entry_insert)]
24662465
/// use std::collections::HashMap;
24672466
///
24682467
/// let mut map: HashMap<&str, String> = HashMap::new();
2469-
/// let entry = map.entry("poneyland").insert("hoho".to_string());
2468+
/// let entry = map.entry("poneyland").insert_entry("hoho".to_string());
24702469
///
24712470
/// assert_eq!(entry.key(), &"poneyland");
24722471
/// ```
24732472
#[inline]
2474-
#[unstable(feature = "entry_insert", issue = "65225")]
2475-
pub fn insert(self, value: V) -> OccupiedEntry<'a, K, V> {
2473+
#[stable(feature = "entry_insert", since = "1.59.0")]
2474+
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
24762475
match self {
24772476
Occupied(mut entry) => {
24782477
entry.insert(value);
@@ -2811,12 +2810,13 @@ impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
28112810
/// let mut map: HashMap<&str, u32> = HashMap::new();
28122811
///
28132812
/// if let Entry::Vacant(o) = map.entry("poneyland") {
2814-
/// o.insert(37);
2813+
/// o.insert_entry(37);
28152814
/// }
28162815
/// assert_eq!(map["poneyland"], 37);
28172816
/// ```
28182817
#[inline]
2819-
fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
2818+
#[stable(feature = "entry_insert", since = "1.59.0")]
2819+
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
28202820
let base = self.base.insert_entry(value);
28212821
OccupiedEntry { base }
28222822
}

0 commit comments

Comments
 (0)