Skip to content

Commit c2de8fe

Browse files
committed
Stabilize or_insert_with_key
1 parent 98e1688 commit c2de8fe

File tree

3 files changed

+3
-5
lines changed
  • compiler/rustc_data_structures/src/sso
  • library

3 files changed

+3
-5
lines changed

compiler/rustc_data_structures/src/sso/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SSO_ARRAY_SIZE: usize = 8;
4040
// into_keys/into_values (unstable)
4141
// all raw_entry-related
4242
// PartialEq/Eq (requires sorting the array)
43-
// Entry::or_insert_with_key (unstable)
43+
// Entry::or_insert_with_key
4444
// Vacant/Occupied entries and related
4545
//
4646
// FIXME: In HashMap most methods accepting key reference

library/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(),

library/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)