@@ -952,7 +952,7 @@ where
952
952
/// ```
953
953
#[ inline]
954
954
#[ 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 ]
956
956
where
957
957
K : Borrow < Q > ,
958
958
Q : Hash + Eq ,
@@ -1011,7 +1011,7 @@ where
1011
1011
pub unsafe fn get_many_unchecked_mut < Q : ?Sized , const N : usize > (
1012
1012
& mut self ,
1013
1013
ks : [ & Q ; N ] ,
1014
- ) -> Option < [ & ' _ mut V ; N ] >
1014
+ ) -> [ Option < & ' _ mut V > ; N ]
1015
1015
where
1016
1016
K : Borrow < Q > ,
1017
1017
Q : Hash + Eq ,
@@ -1407,6 +1407,14 @@ impl<K, V> Clone for Iter<'_, K, V> {
1407
1407
}
1408
1408
}
1409
1409
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
+
1410
1418
#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
1411
1419
impl < K : Debug , V : Debug > fmt:: Debug for Iter < ' _ , K , V > {
1412
1420
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -1445,6 +1453,14 @@ impl<'a, K, V> IterMut<'a, K, V> {
1445
1453
}
1446
1454
}
1447
1455
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
+
1448
1464
/// An owning iterator over the entries of a `HashMap`.
1449
1465
///
1450
1466
/// This `struct` is created by the [`into_iter`] method on [`HashMap`]
@@ -1475,6 +1491,14 @@ impl<K, V> IntoIter<K, V> {
1475
1491
}
1476
1492
}
1477
1493
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
+
1478
1502
/// An iterator over the keys of a `HashMap`.
1479
1503
///
1480
1504
/// This `struct` is created by the [`keys`] method on [`HashMap`]. See its
@@ -1507,6 +1531,14 @@ impl<K, V> Clone for Keys<'_, K, V> {
1507
1531
}
1508
1532
}
1509
1533
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
+
1510
1542
#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
1511
1543
impl < K : Debug , V > fmt:: Debug for Keys < ' _ , K , V > {
1512
1544
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -1546,6 +1578,14 @@ impl<K, V> Clone for Values<'_, K, V> {
1546
1578
}
1547
1579
}
1548
1580
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
+
1549
1589
#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
1550
1590
impl < K , V : Debug > fmt:: Debug for Values < ' _ , K , V > {
1551
1591
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -1634,6 +1674,14 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
1634
1674
inner : IterMut < ' a , K , V > ,
1635
1675
}
1636
1676
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
+
1637
1685
/// An owning iterator over the keys of a `HashMap`.
1638
1686
///
1639
1687
/// This `struct` is created by the [`into_keys`] method on [`HashMap`].
@@ -1656,6 +1704,14 @@ pub struct IntoKeys<K, V> {
1656
1704
inner : IntoIter < K , V > ,
1657
1705
}
1658
1706
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
+
1659
1715
/// An owning iterator over the values of a `HashMap`.
1660
1716
///
1661
1717
/// This `struct` is created by the [`into_values`] method on [`HashMap`].
@@ -1678,6 +1734,14 @@ pub struct IntoValues<K, V> {
1678
1734
inner : IntoIter < K , V > ,
1679
1735
}
1680
1736
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
+
1681
1745
/// A builder for computing where in a HashMap a key-value pair would be stored.
1682
1746
///
1683
1747
/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
@@ -2978,64 +3042,6 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
2978
3042
pub fn remove ( self ) -> V {
2979
3043
self . base . remove ( )
2980
3044
}
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
- }
3039
3045
}
3040
3046
3041
3047
impl < ' a , K : ' a , V : ' a > VacantEntry < ' a , K , V > {
0 commit comments