We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
last
count
1 parent 675defb commit 6192cf8Copy full SHA for 6192cf8
core/src/iter/sources/repeat.rs
@@ -9,7 +9,7 @@ use crate::num::NonZero;
9
/// [`Iterator::take()`], in order to make them finite.
10
///
11
/// Use [`str::repeat()`] instead of this function if you just want to repeat
12
-/// a char/string `n`th times.
+/// a char/string `n` times.
13
14
/// If the element type of the iterator you need does not implement `Clone`,
15
/// or if you do not want to keep the repeated element in memory, you can
@@ -98,11 +98,12 @@ impl<A: Clone> Iterator for Repeat<A> {
98
}
99
100
fn last(self) -> Option<A> {
101
- loop {}
+ Some(self.element)
102
103
104
+ #[track_caller]
105
fn count(self) -> usize {
106
+ panic!("iterator is infinite");
107
108
109
0 commit comments