Skip to content

Commit c82ee98

Browse files
committed
impl Default for Hash{Map,Set} iterators that don't already have it
1 parent 06bb836 commit c82ee98

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

library/Cargo.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is automatically @generated by Cargo.
22
# It is not intended for manual editing.
3-
version = 3
3+
version = 4
44

55
[[package]]
66
name = "addr2line"
@@ -42,9 +42,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
4242

4343
[[package]]
4444
name = "cc"
45-
version = "1.1.22"
45+
version = "1.1.24"
4646
source = "registry+https://github.com/rust-lang/crates.io-index"
47-
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
47+
checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
4848
dependencies = [
4949
"shlex",
5050
]
@@ -135,9 +135,9 @@ dependencies = [
135135

136136
[[package]]
137137
name = "hashbrown"
138-
version = "0.14.5"
138+
version = "0.15.0"
139139
source = "registry+https://github.com/rust-lang/crates.io-index"
140-
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
140+
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
141141
dependencies = [
142142
"allocator-api2",
143143
"compiler_builtins",

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ core = { path = "../core", public = true }
2020
compiler_builtins = { version = "0.1.130" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }
23-
hashbrown = { version = "0.14", default-features = false, features = [
23+
hashbrown = { version = "0.15", default-features = false, features = [
2424
'rustc-dep-of-std',
2525
] }
2626
# FIXME(#127890): `object` depends on `memchr`, but `memchr` > v2.5 causes

library/std/src/collections/hash/map.rs

+64
Original file line numberDiff line numberDiff line change
@@ -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")]
14111419
impl<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")]
15111543
impl<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")]
15501590
impl<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.

library/std/src/collections/hash/set.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,14 @@ pub struct Iter<'a, K: 'a> {
12761276
base: base::Iter<'a, K>,
12771277
}
12781278

1279+
#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
1280+
impl<K> Default for Iter<'_, K> {
1281+
#[inline]
1282+
fn default() -> Self {
1283+
Iter { base: Default::default() }
1284+
}
1285+
}
1286+
12791287
/// An owning iterator over the items of a `HashSet`.
12801288
///
12811289
/// This `struct` is created by the [`into_iter`] method on [`HashSet`]
@@ -1297,6 +1305,14 @@ pub struct IntoIter<K> {
12971305
base: base::IntoIter<K>,
12981306
}
12991307

1308+
#[stable(feature = "default_iters_hash", since = "CURRENT_RUSTC_VERSION")]
1309+
impl<K> Default for IntoIter<K> {
1310+
#[inline]
1311+
fn default() -> Self {
1312+
IntoIter { base: Default::default() }
1313+
}
1314+
}
1315+
13001316
/// A draining iterator over the items of a `HashSet`.
13011317
///
13021318
/// This `struct` is created by the [`drain`] method on [`HashSet`].

0 commit comments

Comments
 (0)