Skip to content

Commit 6f693e9

Browse files
committed
Stabilize Entry types
This commit marks as `#[stable]` the `Entry` types for the maps provided by `std`. The main reason these had been left unstable previously was uncertainty about an eventual trait design, but several plausible designs have been proposed that all work fine with the current type definitions.
1 parent 0084f92 commit 6f693e9

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

src/libcollections/btree/map.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -124,26 +124,26 @@ pub struct RangeMut<'a, K: 'a, V: 'a> {
124124
}
125125

126126
/// A view into a single entry in a map, which may either be vacant or occupied.
127-
#[unstable(feature = "collections",
128-
reason = "precise API still under development")]
127+
#[stable(feature = "rust1", since = "1.0.0")]
129128
pub enum Entry<'a, K:'a, V:'a> {
130129
/// A vacant Entry
130+
#[stable(feature = "rust1", since = "1.0.0")]
131131
Vacant(VacantEntry<'a, K, V>),
132+
132133
/// An occupied Entry
134+
#[stable(feature = "rust1", since = "1.0.0")]
133135
Occupied(OccupiedEntry<'a, K, V>),
134136
}
135137

136138
/// A vacant Entry.
137-
#[unstable(feature = "collections",
138-
reason = "precise API still under development")]
139+
#[stable(feature = "rust1", since = "1.0.0")]
139140
pub struct VacantEntry<'a, K:'a, V:'a> {
140141
key: K,
141142
stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
142143
}
143144

144145
/// An occupied Entry.
145-
#[unstable(feature = "collections",
146-
reason = "precise API still under development")]
146+
#[stable(feature = "rust1", since = "1.0.0")]
147147
pub struct OccupiedEntry<'a, K:'a, V:'a> {
148148
stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
149149
}
@@ -1124,9 +1124,9 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
11241124
}
11251125

11261126
impl<'a, K: Ord, V> Entry<'a, K, V> {
1127-
#[unstable(feature = "collections",
1128-
reason = "matches collection reform v2 specification, waiting for dust to settle")]
11291127
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
1128+
#[unstable(feature = "std_misc",
1129+
reason = "will soon be replaced by or_insert")]
11301130
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
11311131
match self {
11321132
Occupied(entry) => Ok(entry.into_mut()),

src/libcollections/vec_map.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,28 @@ pub struct VecMap<V> {
6767
}
6868

6969
/// A view into a single entry in a map, which may either be vacant or occupied.
70-
#[unstable(feature = "collections",
71-
reason = "precise API still under development")]
70+
71+
#[stable(feature = "rust1", since = "1.0.0")]
7272
pub enum Entry<'a, V:'a> {
7373
/// A vacant Entry
74+
#[stable(feature = "rust1", since = "1.0.0")]
7475
Vacant(VacantEntry<'a, V>),
76+
7577
/// An occupied Entry
78+
#[stable(feature = "rust1", since = "1.0.0")]
7679
Occupied(OccupiedEntry<'a, V>),
7780
}
7881

7982
/// A vacant Entry.
80-
#[unstable(feature = "collections",
81-
reason = "precise API still under development")]
83+
84+
#[stable(feature = "rust1", since = "1.0.0")]
8285
pub struct VacantEntry<'a, V:'a> {
8386
map: &'a mut VecMap<V>,
8487
index: usize,
8588
}
8689

8790
/// An occupied Entry.
88-
#[unstable(feature = "collections",
89-
reason = "precise API still under development")]
91+
#[stable(feature = "rust1", since = "1.0.0")]
9092
pub struct OccupiedEntry<'a, V:'a> {
9193
map: &'a mut VecMap<V>,
9294
index: usize,
@@ -651,7 +653,7 @@ impl<V> VecMap<V> {
651653

652654
impl<'a, V> Entry<'a, V> {
653655
#[unstable(feature = "collections",
654-
reason = "matches collection reform v2 specification, waiting for dust to settle")]
656+
reason = "will soon be replaced by or_insert")]
655657
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
656658
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, V>> {
657659
match self {

src/libstd/collections/hash/map.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1335,28 +1335,28 @@ pub struct Drain<'a, K: 'a, V: 'a> {
13351335
}
13361336

13371337
/// A view into a single occupied location in a HashMap.
1338-
#[unstable(feature = "std_misc",
1339-
reason = "precise API still being fleshed out")]
1338+
#[stable(feature = "rust1", since = "1.0.0")]
13401339
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
13411340
elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
13421341
}
13431342

13441343
/// A view into a single empty location in a HashMap.
1345-
#[unstable(feature = "std_misc",
1346-
reason = "precise API still being fleshed out")]
1344+
#[stable(feature = "rust1", since = "1.0.0")]
13471345
pub struct VacantEntry<'a, K: 'a, V: 'a> {
13481346
hash: SafeHash,
13491347
key: K,
13501348
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
13511349
}
13521350

13531351
/// A view into a single location in a map, which may be vacant or occupied.
1354-
#[unstable(feature = "std_misc",
1355-
reason = "precise API still being fleshed out")]
1352+
#[stable(feature = "rust1", since = "1.0.0")]
13561353
pub enum Entry<'a, K: 'a, V: 'a> {
13571354
/// An occupied Entry.
1355+
#[stable(feature = "rust1", since = "1.0.0")]
13581356
Occupied(OccupiedEntry<'a, K, V>),
1357+
13591358
/// A vacant Entry.
1359+
#[stable(feature = "rust1", since = "1.0.0")]
13601360
Vacant(VacantEntry<'a, K, V>),
13611361
}
13621362

@@ -1477,10 +1477,10 @@ impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> {
14771477
#[inline] fn len(&self) -> usize { self.inner.len() }
14781478
}
14791479

1480-
#[unstable(feature = "std_misc",
1481-
reason = "matches collection reform v2 specification, waiting for dust to settle")]
14821480
impl<'a, K, V> Entry<'a, K, V> {
14831481
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant.
1482+
#[unstable(feature = "std_misc",
1483+
reason = "will soon be replaced by or_insert")]
14841484
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
14851485
match self {
14861486
Occupied(entry) => Ok(entry.into_mut()),

0 commit comments

Comments
 (0)