]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/collections/hash/map.rs
Rollup merge of #90345 - passcod:entry-insert, r=dtolnay
[rust.git] / library / std / src / collections / hash / map.rs
index 35f17aa781f4e3a1e025936e1b6227af605c7144..5ef23871e8b5f37f9c4d369e07fe30b161cc5ee2 100644 (file)
@@ -2462,17 +2462,16 @@ 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();
-    /// let entry = map.entry("poneyland").insert("hoho".to_string());
+    /// let entry = map.entry("poneyland").insert_entry("hoho".to_string());
     ///
     /// assert_eq!(entry.key(), &"poneyland");
     /// ```
     #[inline]
-    #[unstable(feature = "entry_insert", issue = "65225")]
-    pub fn insert(self, value: V) -> OccupiedEntry<'a, K, V> {
+    #[stable(feature = "entry_insert", since = "1.59.0")]
+    pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
         match self {
             Occupied(mut entry) => {
                 entry.insert(value);
@@ -2811,12 +2810,13 @@ pub fn insert(self, value: V) -> &'a mut V {
     /// let mut map: HashMap<&str, u32> = HashMap::new();
     ///
     /// if let Entry::Vacant(o) = map.entry("poneyland") {
-    ///     o.insert(37);
+    ///     o.insert_entry(37);
     /// }
     /// assert_eq!(map["poneyland"], 37);
     /// ```
     #[inline]
-    fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
+    #[stable(feature = "entry_insert", since = "1.59.0")]
+    pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V> {
         let base = self.base.insert_entry(value);
         OccupiedEntry { base }
     }