Skip to content

Commit 5174136

Browse files
committed
Stabilize or_insert_with_key
1 parent 2eebf58 commit 5174136

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

alloc/src/collections/btree/map/entry.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,13 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
116116
}
117117
}
118118

119-
#[unstable(feature = "or_insert_with_key", issue = "71024")]
120119
/// Ensures a value is in the entry by inserting, if empty, the result of the default function,
121120
/// which takes the key as its argument, and returns a mutable reference to the value in the
122121
/// entry.
123122
///
124123
/// # Examples
125124
///
126125
/// ```
127-
/// #![feature(or_insert_with_key)]
128126
/// use std::collections::BTreeMap;
129127
///
130128
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
@@ -134,6 +132,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
134132
/// assert_eq!(map["poneyland"], 9);
135133
/// ```
136134
#[inline]
135+
#[stable(feature = "or_insert_with_key", since = "1.49.0")]
137136
pub fn or_insert_with_key<F: FnOnce(&K) -> V>(self, default: F) -> &'a mut V {
138137
match self {
139138
Occupied(entry) => entry.into_mut(),

std/src/collections/hash/map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,6 @@ impl<'a, K, V> Entry<'a, K, V> {
22292229
/// # Examples
22302230
///
22312231
/// ```
2232-
/// #![feature(or_insert_with_key)]
22332232
/// use std::collections::HashMap;
22342233
///
22352234
/// let mut map: HashMap<&str, usize> = HashMap::new();
@@ -2239,7 +2238,7 @@ impl<'a, K, V> Entry<'a, K, V> {
22392238
/// assert_eq!(map["poneyland"], 9);
22402239
/// ```
22412240
#[inline]
2242-
#[unstable(feature = "or_insert_with_key", issue = "71024")]
2241+
#[stable(feature = "or_insert_with_key", since = "1.49.0")]
22432242
pub fn or_insert_with_key<F: FnOnce(&K) -> V>(self, default: F) -> &'a mut V {
22442243
match self {
22452244
Occupied(entry) => entry.into_mut(),

0 commit comments

Comments
 (0)