diff --git a/src/map.rs b/src/map.rs index a7f81debd..067ade154 100644 --- a/src/map.rs +++ b/src/map.rs @@ -2447,6 +2447,14 @@ pub struct IntoKeys { inner: IntoIter, } +impl Default for IntoKeys { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} impl Iterator for IntoKeys { type Item = K; @@ -2517,6 +2525,14 @@ pub struct IntoValues { inner: IntoIter, } +impl Default for IntoValues { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} impl Iterator for IntoValues { type Item = V; @@ -4720,6 +4736,15 @@ impl IntoIterator for HashMap { } } +impl<'a, K, V> Default for Iter<'a, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + marker: PhantomData, + } + } +} impl<'a, K, V> Iterator for Iter<'a, K, V> { type Item = (&'a K, &'a V); @@ -4759,6 +4784,15 @@ impl ExactSizeIterator for Iter<'_, K, V> { impl FusedIterator for Iter<'_, K, V> {} +impl<'a, K, V> Default for IterMut<'a, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + marker: PhantomData, + } + } +} impl<'a, K, V> Iterator for IterMut<'a, K, V> { type Item = (&'a K, &'a mut V); @@ -4807,6 +4841,14 @@ where } } +impl Default for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} impl Iterator for IntoIter { type Item = (K, V); @@ -4841,6 +4883,14 @@ impl fmt::Debug for IntoIter { } } +impl<'a, K, V> Default for Keys<'a, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} impl<'a, K, V> Iterator for Keys<'a, K, V> { type Item = &'a K; @@ -4873,6 +4923,14 @@ impl ExactSizeIterator for Keys<'_, K, V> { } impl FusedIterator for Keys<'_, K, V> {} +impl<'a, K, V> Default for Values<'a, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} impl<'a, K, V> Iterator for Values<'a, K, V> { type Item = &'a V; @@ -4905,6 +4963,14 @@ impl ExactSizeIterator for Values<'_, K, V> { } impl FusedIterator for Values<'_, K, V> {} +impl<'a, K, V> Default for ValuesMut<'a, K, V> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Self { + inner: Default::default(), + } + } +} impl<'a, K, V> Iterator for ValuesMut<'a, K, V> { type Item = &'a mut V; diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 1e31247cb..d69ac59a7 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -4112,6 +4112,13 @@ impl Clone for RawIter { } } } +impl Default for RawIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + // SAFETY: Because the table is static, it always outlives the iter. + unsafe { RawTableInner::NEW.iter() } + } +} impl Iterator for RawIter { type Item = Bucket; @@ -4330,6 +4337,15 @@ impl Drop for RawIntoIter { } } +impl Default for RawIntoIter { + fn default() -> Self { + Self { + iter: Default::default(), + allocation: None, + marker: PhantomData, + } + } +} impl Iterator for RawIntoIter { type Item = T; diff --git a/src/set.rs b/src/set.rs index fea591990..6baa2d63a 100644 --- a/src/set.rs +++ b/src/set.rs @@ -1832,6 +1832,14 @@ impl Clone for Iter<'_, K> { } } } +impl Default for Iter<'_, K> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Iter { + iter: Default::default(), + } + } +} impl<'a, K> Iterator for Iter<'a, K> { type Item = &'a K; @@ -1866,6 +1874,14 @@ impl fmt::Debug for Iter<'_, K> { } } +impl Default for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IntoIter { + iter: Default::default(), + } + } +} impl Iterator for IntoIter { type Item = K; diff --git a/src/table.rs b/src/table.rs index 694d46416..13f67573b 100644 --- a/src/table.rs +++ b/src/table.rs @@ -1835,6 +1835,15 @@ pub struct Iter<'a, T> { marker: PhantomData<&'a T>, } +impl<'a, T> Default for Iter<'a, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + Iter { + inner: Default::default(), + marker: PhantomData, + } + } +} impl<'a, T> Iterator for Iter<'a, T> { type Item = &'a T; @@ -1881,6 +1890,15 @@ pub struct IterMut<'a, T> { marker: PhantomData<&'a mut T>, } +impl<'a, T> Default for IterMut<'a, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IterMut { + inner: Default::default(), + marker: PhantomData, + } + } +} impl<'a, T> Iterator for IterMut<'a, T> { type Item = &'a mut T; @@ -1931,6 +1949,14 @@ where inner: RawIntoIter, } +impl Default for IntoIter { + #[cfg_attr(feature = "inline-more", inline)] + fn default() -> Self { + IntoIter { + inner: Default::default(), + } + } +} impl Iterator for IntoIter where A: Allocator,