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.
1 parent 42b384e commit d52744eCopy full SHA for d52744e
library/core/src/iter/sources/repeat.rs
@@ -97,8 +97,9 @@ impl<A: Clone> Iterator for Repeat<A> {
97
Some(self.element.clone())
98
}
99
100
+ #[track_caller]
101
fn last(self) -> Option<A> {
- Some(self.element)
102
+ panic!("iterator is infinite");
103
104
105
#[track_caller]
library/coretests/tests/iter/sources.rs
@@ -37,6 +37,7 @@ fn test_repeat_count() {
37
38
39
#[test]
40
+#[should_panic = "iterator is infinite"]
41
fn test_repeat_last() {
42
assert_eq!(repeat(42).last(), Some(42));
43
0 commit comments