Skip to content

Commit 7293765

Browse files
committed
Iterator repeat: no infinite loop for last and count
1 parent 7ad23f4 commit 7293765

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/iter/sources/repeat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ impl<A: Clone> Iterator for Repeat<A> {
9898
}
9999

100100
fn last(self) -> Option<A> {
101-
loop {}
101+
Some(self.element)
102102
}
103103

104104
fn count(self) -> usize {
105-
loop {}
105+
panic!("iterator is infinite");
106106
}
107107
}
108108

0 commit comments

Comments
 (0)