@@ -116,15 +116,16 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
116
116
}
117
117
}
118
118
119
- #[ unstable( feature = "or_insert_with_key" , issue = "71024" ) ]
120
- /// Ensures a value is in the entry by inserting, if empty, the result of the default function,
121
- /// which takes the key as its argument, and returns a mutable reference to the value in the
122
- /// entry.
119
+ /// Ensures a value is in the entry by inserting, if empty, the result of the default function.
120
+ /// This method allows for generating key-derived values for insertion by providing the default
121
+ /// function a reference to the key that was moved during the `.entry(key)` method call.
122
+ ///
123
+ /// The reference to the moved key is provided so that cloning or copying the key is
124
+ /// unnecessary, unlike with `.or_insert_with(|| ... )`.
123
125
///
124
126
/// # Examples
125
127
///
126
128
/// ```
127
- /// #![feature(or_insert_with_key)]
128
129
/// use std::collections::BTreeMap;
129
130
///
130
131
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
@@ -134,6 +135,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
134
135
/// assert_eq!(map["poneyland"], 9);
135
136
/// ```
136
137
#[ inline]
138
+ #[ stable( feature = "or_insert_with_key" , since = "1.50.0" ) ]
137
139
pub fn or_insert_with_key < F : FnOnce ( & K ) -> V > ( self , default : F ) -> & ' a mut V {
138
140
match self {
139
141
Occupied ( entry) => entry. into_mut ( ) ,
0 commit comments