]> git.lizzy.rs Git - rust.git/commitdiff
std: Revert stability of Entry-based APIs
authorAlex Crichton <alex@alexcrichton.com>
Tue, 6 Jan 2015 18:25:12 +0000 (10:25 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 6 Jan 2015 19:59:26 +0000 (11:59 -0800)
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.

src/libcollections/btree/map.rs
src/libstd/collections/hash/map.rs

index 6e8b1a662ce76a84879210603384f2d65f35fb34..0a0bb5b876574e9fc797004849d7a1f1c01a533a 100644 (file)
@@ -128,8 +128,8 @@ pub struct Values<'a, K: 'a, V: 'a> {
     inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
 }
 
-#[stable]
 /// A view into a single entry in a map, which may either be vacant or occupied.
+#[unstable = "precise API still under development"]
 pub enum Entry<'a, K:'a, V:'a> {
     /// A vacant Entry
     Vacant(VacantEntry<'a, K, V>),
@@ -137,15 +137,15 @@ pub enum Entry<'a, K:'a, V:'a> {
     Occupied(OccupiedEntry<'a, K, V>),
 }
 
-#[stable]
 /// A vacant Entry.
+#[unstable = "precise API still under development"]
 pub struct VacantEntry<'a, K:'a, V:'a> {
     key: K,
     stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
 }
 
-#[stable]
 /// An occupied Entry.
+#[unstable = "precise API still under development"]
 pub struct OccupiedEntry<'a, K:'a, V:'a> {
     stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
 }
@@ -1123,43 +1123,43 @@ pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
 }
 
 impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
-    #[stable]
     /// Sets the value of the entry with the VacantEntry's key,
     /// and returns a mutable reference to it.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn insert(self, value: V) -> &'a mut V {
         self.stack.insert(self.key, value)
     }
 }
 
 impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
-    #[stable]
     /// Gets a reference to the value in the entry.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn get(&self) -> &V {
         self.stack.peek()
     }
 
-    #[stable]
     /// Gets a mutable reference to the value in the entry.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn get_mut(&mut self) -> &mut V {
         self.stack.peek_mut()
     }
 
-    #[stable]
     /// Converts the entry into a mutable reference to its value.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn into_mut(self) -> &'a mut V {
         self.stack.into_top()
     }
 
-    #[stable]
     /// Sets the value of the entry with the OccupiedEntry's key,
     /// and returns the entry's old value.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn insert(&mut self, mut value: V) -> V {
         mem::swap(self.stack.peek_mut(), &mut value);
         value
     }
 
-    #[stable]
     /// Takes the value of the entry out of the map, and returns it.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn remove(self) -> V {
         self.stack.remove()
     }
@@ -1361,7 +1361,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
     /// assert_eq!(count["a"], 3u);
     /// ```
     /// The key must have the same ordering before or after `.to_owned()` is called.
-    #[stable]
+    #[unstable = "precise API still under development"]
     pub fn entry<'a>(&'a mut self, mut key: K) -> Entry<'a, K, V> {
         // same basic logic of `swap` and `pop`, blended together
         let mut stack = stack::PartialSearchStack::new(self);
index ae53bc615992cf614047bebad2304fdac33a529d..a01158fb1ed2759080e6a9945b626f8ed94eb7a4 100644 (file)
@@ -920,8 +920,8 @@ fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) }
         }
     }
 
-    #[stable]
     /// Gets the given key's corresponding entry in the map for in-place manipulation.
+    #[unstable = "precise API still being fleshed out"]
     pub fn entry<'a>(&'a mut self, key: K) -> Entry<'a, K, V>
     {
         // Gotta resize now.
@@ -1320,22 +1320,22 @@ pub struct Drain<'a, K: 'a, V: 'a> {
     >
 }
 
-#[stable]
 /// A view into a single occupied location in a HashMap
+#[unstable = "precise API still being fleshed out"]
 pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
     elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
 }
 
-#[stable]
 /// A view into a single empty location in a HashMap
+#[unstable = "precise API still being fleshed out"]
 pub struct VacantEntry<'a, K: 'a, V: 'a> {
     hash: SafeHash,
     key: K,
     elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
 }
 
-#[stable]
 /// A view into a single location in a map, which may be vacant or occupied
+#[unstable = "precise API still being fleshed out"]
 pub enum Entry<'a, K: 'a, V: 'a> {
     /// An occupied Entry
     Occupied(OccupiedEntry<'a, K, V>),
@@ -1406,8 +1406,8 @@ fn size_hint(&self) -> (uint, Option<uint>) {
     }
 }
 
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
 impl<'a, K, V> Entry<'a, K, V> {
-    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
     pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
         match self {
@@ -1417,27 +1417,24 @@ pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
     }
 }
 
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
 impl<'a, K, V> OccupiedEntry<'a, K, V> {
-    #[stable]
     /// Gets a reference to the value in the entry
     pub fn get(&self) -> &V {
         self.elem.read().1
     }
 
-    #[stable]
     /// Gets a mutable reference to the value in the entry
     pub fn get_mut(&mut self) -> &mut V {
         self.elem.read_mut().1
     }
 
-    #[stable]
     /// Converts the OccupiedEntry into a mutable reference to the value in the entry
     /// with a lifetime bound to the map itself
     pub fn into_mut(self) -> &'a mut V {
         self.elem.into_mut_refs().1
     }
 
-    #[stable]
     /// Sets the value of the entry, and returns the entry's old value
     pub fn insert(&mut self, mut value: V) -> V {
         let old_value = self.get_mut();
@@ -1445,15 +1442,14 @@ pub fn insert(&mut self, mut value: V) -> V {
         value
     }
 
-    #[stable]
     /// Takes the value out of the entry, and returns it
     pub fn remove(self) -> V {
         pop_internal(self.elem).1
     }
 }
 
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
 impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
-    #[stable]
     /// Sets the value of the entry with the VacantEntry's key,
     /// and returns a mutable reference to it
     pub fn insert(self, value: V) -> &'a mut V {