Skip to content
/ rust Public
forked from rust-lang/rust

Commit f91b0c5

Browse files
authored
Rollup merge of rust-lang#157323 - majiayu000:docs-repeat-last-panic, r=jhpratt
Document Repeat::last panic behavior Fixes rust-lang#149707 Documents that `Repeat::last` always panics because `Repeat` is infinite. Tests: - `./x fmt --check` - `./x doc library/core` - `./x test library/core`
2 parents 20f07c4 + a23630f commit f91b0c5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,21 @@ impl<A: Clone> Iterator for Repeat<A> {
101101
Some(self.element.clone())
102102
}
103103

104+
/// Consumes the iterator and panics.
105+
///
106+
/// # Panics
107+
///
108+
/// This method always panics because `Repeat` is infinite.
104109
#[track_caller]
105110
fn last(self) -> Option<A> {
106111
panic!("iterator is infinite");
107112
}
108113

114+
/// Consumes the iterator and panics.
115+
///
116+
/// # Panics
117+
///
118+
/// This method always panics because `Repeat` is infinite.
109119
#[track_caller]
110120
fn count(self) -> usize {
111121
panic!("iterator is infinite");

0 commit comments

Comments
 (0)