summaryrefslogtreecommitdiffstats
path: root/library/core/src/iter/adapters/cloned.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/core/src/iter/adapters/cloned.rs')
-rw-r--r--library/core/src/iter/adapters/cloned.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/library/core/src/iter/adapters/cloned.rs b/library/core/src/iter/adapters/cloned.rs
index 914ff86c1..d3cceb8d4 100644
--- a/library/core/src/iter/adapters/cloned.rs
+++ b/library/core/src/iter/adapters/cloned.rs
@@ -153,3 +153,17 @@ where
item.clone()
}
}
+
+#[stable(feature = "default_iters", since = "1.70.0")]
+impl<I: Default> Default for Cloned<I> {
+ /// Creates a `Cloned` iterator from the default value of `I`
+ /// ```
+ /// # use core::slice;
+ /// # use core::iter::Cloned;
+ /// let iter: Cloned<slice::Iter<'_, u8>> = Default::default();
+ /// assert_eq!(iter.len(), 0);
+ /// ```
+ fn default() -> Self {
+ Self::new(Default::default())
+ }
+}