@@ -952,7 +952,7 @@ where
952952 /// ```
953953 #[ inline]
954954 #[ unstable( feature = "map_many_mut" , issue = "97601" ) ]
955- pub fn get_many_mut < Q : ?Sized , const N : usize > ( & mut self , ks : [ & Q ; N ] ) -> Option < [ & ' _ mut V ; N ] >
955+ pub fn get_many_mut < Q : ?Sized , const N : usize > ( & mut self , ks : [ & Q ; N ] ) -> [ Option < & ' _ mut V > ; N ]
956956 where
957957 K : Borrow < Q > ,
958958 Q : Hash + Eq ,
@@ -1011,7 +1011,7 @@ where
10111011 pub unsafe fn get_many_unchecked_mut < Q : ?Sized , const N : usize > (
10121012 & mut self ,
10131013 ks : [ & Q ; N ] ,
1014- ) -> Option < [ & ' _ mut V ; N ] >
1014+ ) -> [ Option < & ' _ mut V > ; N ]
10151015 where
10161016 K : Borrow < Q > ,
10171017 Q : Hash + Eq ,
@@ -1407,6 +1407,14 @@ impl<K, V> Clone for Iter<'_, K, V> {
14071407 }
14081408}
14091409
1410+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1411+ impl < K , V > Default for Iter < ' _ , K , V > {
1412+ #[ inline]
1413+ fn default ( ) -> Self {
1414+ Iter { base : Default :: default ( ) }
1415+ }
1416+ }
1417+
14101418#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
14111419impl < K : Debug , V : Debug > fmt:: Debug for Iter < ' _ , K , V > {
14121420 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -1445,6 +1453,14 @@ impl<'a, K, V> IterMut<'a, K, V> {
14451453 }
14461454}
14471455
1456+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1457+ impl < K , V > Default for IterMut < ' _ , K , V > {
1458+ #[ inline]
1459+ fn default ( ) -> Self {
1460+ IterMut { base : Default :: default ( ) }
1461+ }
1462+ }
1463+
14481464/// An owning iterator over the entries of a `HashMap`.
14491465///
14501466/// This `struct` is created by the [`into_iter`] method on [`HashMap`]
@@ -1475,6 +1491,14 @@ impl<K, V> IntoIter<K, V> {
14751491 }
14761492}
14771493
1494+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1495+ impl < K , V > Default for IntoIter < K , V > {
1496+ #[ inline]
1497+ fn default ( ) -> Self {
1498+ IntoIter { base : Default :: default ( ) }
1499+ }
1500+ }
1501+
14781502/// An iterator over the keys of a `HashMap`.
14791503///
14801504/// This `struct` is created by the [`keys`] method on [`HashMap`]. See its
@@ -1507,6 +1531,14 @@ impl<K, V> Clone for Keys<'_, K, V> {
15071531 }
15081532}
15091533
1534+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1535+ impl < K , V > Default for Keys < ' _ , K , V > {
1536+ #[ inline]
1537+ fn default ( ) -> Self {
1538+ Keys { inner : Default :: default ( ) }
1539+ }
1540+ }
1541+
15101542#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
15111543impl < K : Debug , V > fmt:: Debug for Keys < ' _ , K , V > {
15121544 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -1546,6 +1578,14 @@ impl<K, V> Clone for Values<'_, K, V> {
15461578 }
15471579}
15481580
1581+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1582+ impl < K , V > Default for Values < ' _ , K , V > {
1583+ #[ inline]
1584+ fn default ( ) -> Self {
1585+ Values { inner : Default :: default ( ) }
1586+ }
1587+ }
1588+
15491589#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
15501590impl < K , V : Debug > fmt:: Debug for Values < ' _ , K , V > {
15511591 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -1634,6 +1674,14 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
16341674 inner : IterMut < ' a , K , V > ,
16351675}
16361676
1677+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1678+ impl < K , V > Default for ValuesMut < ' _ , K , V > {
1679+ #[ inline]
1680+ fn default ( ) -> Self {
1681+ ValuesMut { inner : Default :: default ( ) }
1682+ }
1683+ }
1684+
16371685/// An owning iterator over the keys of a `HashMap`.
16381686///
16391687/// This `struct` is created by the [`into_keys`] method on [`HashMap`].
@@ -1656,6 +1704,14 @@ pub struct IntoKeys<K, V> {
16561704 inner : IntoIter < K , V > ,
16571705}
16581706
1707+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1708+ impl < K , V > Default for IntoKeys < K , V > {
1709+ #[ inline]
1710+ fn default ( ) -> Self {
1711+ IntoKeys { inner : Default :: default ( ) }
1712+ }
1713+ }
1714+
16591715/// An owning iterator over the values of a `HashMap`.
16601716///
16611717/// This `struct` is created by the [`into_values`] method on [`HashMap`].
@@ -1678,6 +1734,14 @@ pub struct IntoValues<K, V> {
16781734 inner : IntoIter < K , V > ,
16791735}
16801736
1737+ #[ stable( feature = "default_iters_hash" , since = "CURRENT_RUSTC_VERSION" ) ]
1738+ impl < K , V > Default for IntoValues < K , V > {
1739+ #[ inline]
1740+ fn default ( ) -> Self {
1741+ IntoValues { inner : Default :: default ( ) }
1742+ }
1743+ }
1744+
16811745/// A builder for computing where in a HashMap a key-value pair would be stored.
16821746///
16831747/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
@@ -2978,64 +3042,6 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
29783042 pub fn remove ( self ) -> V {
29793043 self . base . remove ( )
29803044 }
2981-
2982- /// Replaces the entry, returning the old key and value. The new key in the hash map will be
2983- /// the key used to create this entry.
2984- ///
2985- /// # Examples
2986- ///
2987- /// ```
2988- /// #![feature(map_entry_replace)]
2989- /// use std::collections::hash_map::{Entry, HashMap};
2990- /// use std::rc::Rc;
2991- ///
2992- /// let mut map: HashMap<Rc<String>, u32> = HashMap::new();
2993- /// map.insert(Rc::new("Stringthing".to_string()), 15);
2994- ///
2995- /// let my_key = Rc::new("Stringthing".to_string());
2996- ///
2997- /// if let Entry::Occupied(entry) = map.entry(my_key) {
2998- /// // Also replace the key with a handle to our other key.
2999- /// let (old_key, old_value): (Rc<String>, u32) = entry.replace_entry(16);
3000- /// }
3001- ///
3002- /// ```
3003- #[ inline]
3004- #[ unstable( feature = "map_entry_replace" , issue = "44286" ) ]
3005- pub fn replace_entry ( self , value : V ) -> ( K , V ) {
3006- self . base . replace_entry ( value)
3007- }
3008-
3009- /// Replaces the key in the hash map with the key used to create this entry.
3010- ///
3011- /// # Examples
3012- ///
3013- /// ```
3014- /// #![feature(map_entry_replace)]
3015- /// use std::collections::hash_map::{Entry, HashMap};
3016- /// use std::rc::Rc;
3017- ///
3018- /// let mut map: HashMap<Rc<String>, u32> = HashMap::new();
3019- /// let known_strings: Vec<Rc<String>> = Vec::new();
3020- ///
3021- /// // Initialise known strings, run program, etc.
3022- ///
3023- /// reclaim_memory(&mut map, &known_strings);
3024- ///
3025- /// fn reclaim_memory(map: &mut HashMap<Rc<String>, u32>, known_strings: &[Rc<String>] ) {
3026- /// for s in known_strings {
3027- /// if let Entry::Occupied(entry) = map.entry(Rc::clone(s)) {
3028- /// // Replaces the entry's key with our version of it in `known_strings`.
3029- /// entry.replace_key();
3030- /// }
3031- /// }
3032- /// }
3033- /// ```
3034- #[ inline]
3035- #[ unstable( feature = "map_entry_replace" , issue = "44286" ) ]
3036- pub fn replace_key ( self ) -> K {
3037- self . base . replace_key ( )
3038- }
30393045}
30403046
30413047impl < ' a , K : ' a , V : ' a > VacantEntry < ' a , K , V > {
0 commit comments