Skip to content

Commit 169fbed

Browse files
committed
std: Revert stability of Entry-based APIs
There's been some debate over the precise form that these APIs should take, and they've undergone some changes recently, so these APIs are going to be left unstable for now to be fleshed out during the next release cycle.
1 parent 25eada1 commit 169fbed

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

src/libcollections/btree/map.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,24 @@ pub struct Values<'a, K: 'a, V: 'a> {
128128
inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
129129
}
130130

131-
#[stable]
132131
/// A view into a single entry in a map, which may either be vacant or occupied.
132+
#[unstable = "precise API still under development"]
133133
pub enum Entry<'a, K:'a, V:'a> {
134134
/// A vacant Entry
135135
Vacant(VacantEntry<'a, K, V>),
136136
/// An occupied Entry
137137
Occupied(OccupiedEntry<'a, K, V>),
138138
}
139139

140-
#[stable]
141140
/// A vacant Entry.
141+
#[unstable = "precise API still under development"]
142142
pub struct VacantEntry<'a, K:'a, V:'a> {
143143
key: K,
144144
stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
145145
}
146146

147-
#[stable]
148147
/// An occupied Entry.
148+
#[unstable = "precise API still under development"]
149149
pub struct OccupiedEntry<'a, K:'a, V:'a> {
150150
stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
151151
}
@@ -1123,43 +1123,43 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
11231123
}
11241124

11251125
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
1126-
#[stable]
11271126
/// Sets the value of the entry with the VacantEntry's key,
11281127
/// and returns a mutable reference to it.
1128+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
11291129
pub fn insert(self, value: V) -> &'a mut V {
11301130
self.stack.insert(self.key, value)
11311131
}
11321132
}
11331133

11341134
impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
1135-
#[stable]
11361135
/// Gets a reference to the value in the entry.
1136+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
11371137
pub fn get(&self) -> &V {
11381138
self.stack.peek()
11391139
}
11401140

1141-
#[stable]
11421141
/// Gets a mutable reference to the value in the entry.
1142+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
11431143
pub fn get_mut(&mut self) -> &mut V {
11441144
self.stack.peek_mut()
11451145
}
11461146

1147-
#[stable]
11481147
/// Converts the entry into a mutable reference to its value.
1148+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
11491149
pub fn into_mut(self) -> &'a mut V {
11501150
self.stack.into_top()
11511151
}
11521152

1153-
#[stable]
11541153
/// Sets the value of the entry with the OccupiedEntry's key,
11551154
/// and returns the entry's old value.
1155+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
11561156
pub fn insert(&mut self, mut value: V) -> V {
11571157
mem::swap(self.stack.peek_mut(), &mut value);
11581158
value
11591159
}
11601160

1161-
#[stable]
11621161
/// Takes the value of the entry out of the map, and returns it.
1162+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
11631163
pub fn remove(self) -> V {
11641164
self.stack.remove()
11651165
}
@@ -1361,7 +1361,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
13611361
/// assert_eq!(count["a"], 3u);
13621362
/// ```
13631363
/// The key must have the same ordering before or after `.to_owned()` is called.
1364-
#[stable]
1364+
#[unstable = "precise API still under development"]
13651365
pub fn entry<'a>(&'a mut self, mut key: K) -> Entry<'a, K, V> {
13661366
// same basic logic of `swap` and `pop`, blended together
13671367
let mut stack = stack::PartialSearchStack::new(self);

src/libstd/collections/hash/map.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,8 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
920920
}
921921
}
922922

923-
#[stable]
924923
/// Gets the given key's corresponding entry in the map for in-place manipulation.
924+
#[unstable = "precise API still being fleshed out"]
925925
pub fn entry<'a>(&'a mut self, key: K) -> Entry<'a, K, V>
926926
{
927927
// Gotta resize now.
@@ -1320,22 +1320,22 @@ pub struct Drain<'a, K: 'a, V: 'a> {
13201320
>
13211321
}
13221322

1323-
#[stable]
13241323
/// A view into a single occupied location in a HashMap
1324+
#[unstable = "precise API still being fleshed out"]
13251325
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
13261326
elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
13271327
}
13281328

1329-
#[stable]
13301329
/// A view into a single empty location in a HashMap
1330+
#[unstable = "precise API still being fleshed out"]
13311331
pub struct VacantEntry<'a, K: 'a, V: 'a> {
13321332
hash: SafeHash,
13331333
key: K,
13341334
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
13351335
}
13361336

1337-
#[stable]
13381337
/// A view into a single location in a map, which may be vacant or occupied
1338+
#[unstable = "precise API still being fleshed out"]
13391339
pub enum Entry<'a, K: 'a, V: 'a> {
13401340
/// An occupied Entry
13411341
Occupied(OccupiedEntry<'a, K, V>),
@@ -1406,8 +1406,8 @@ impl<'a, K: 'a, V: 'a> Iterator for Drain<'a, K, V> {
14061406
}
14071407
}
14081408

1409+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
14091410
impl<'a, K, V> Entry<'a, K, V> {
1410-
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
14111411
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
14121412
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
14131413
match self {
@@ -1417,43 +1417,39 @@ impl<'a, K, V> Entry<'a, K, V> {
14171417
}
14181418
}
14191419

1420+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
14201421
impl<'a, K, V> OccupiedEntry<'a, K, V> {
1421-
#[stable]
14221422
/// Gets a reference to the value in the entry
14231423
pub fn get(&self) -> &V {
14241424
self.elem.read().1
14251425
}
14261426

1427-
#[stable]
14281427
/// Gets a mutable reference to the value in the entry
14291428
pub fn get_mut(&mut self) -> &mut V {
14301429
self.elem.read_mut().1
14311430
}
14321431

1433-
#[stable]
14341432
/// Converts the OccupiedEntry into a mutable reference to the value in the entry
14351433
/// with a lifetime bound to the map itself
14361434
pub fn into_mut(self) -> &'a mut V {
14371435
self.elem.into_mut_refs().1
14381436
}
14391437

1440-
#[stable]
14411438
/// Sets the value of the entry, and returns the entry's old value
14421439
pub fn insert(&mut self, mut value: V) -> V {
14431440
let old_value = self.get_mut();
14441441
mem::swap(&mut value, old_value);
14451442
value
14461443
}
14471444

1448-
#[stable]
14491445
/// Takes the value out of the entry, and returns it
14501446
pub fn remove(self) -> V {
14511447
pop_internal(self.elem).1
14521448
}
14531449
}
14541450

1451+
#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
14551452
impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
1456-
#[stable]
14571453
/// Sets the value of the entry with the VacantEntry's key,
14581454
/// and returns a mutable reference to it
14591455
pub fn insert(self, value: V) -> &'a mut V {

0 commit comments

Comments
 (0)