File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
library/core/src/iter/sources Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use crate::num::NonZero;
9
9
/// [`Iterator::take()`], in order to make them finite.
10
10
///
11
11
/// Use [`str::repeat()`] instead of this function if you just want to repeat
12
- /// a char/string `n`th times.
12
+ /// a char/string `n` times.
13
13
///
14
14
/// If the element type of the iterator you need does not implement `Clone`,
15
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
98
}
99
99
100
100
fn last ( self ) -> Option < A > {
101
- loop { }
101
+ Some ( self . element )
102
102
}
103
103
104
+ #[ track_caller]
104
105
fn count ( self ) -> usize {
105
- loop { }
106
+ panic ! ( "iterator is infinite" ) ;
106
107
}
107
108
}
108
109
You can’t perform that action at this time.
0 commit comments