library: Document panic condition for Iterator::last

Added a `# Panics` section to `Iterator::last` to match `Iterator::count`, after the change made in Rust 1.92.0 where now `std::iter::Repeat` panics in these methods instead of doing an infinite `loop`.

Cites https://github.com/rust-lang/rust/issues/149707
This commit is contained in:
Alessio 2026-01-02 03:53:02 +01:00 committed by GitHub
parent 056908d7f4
commit d68c980c22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -236,6 +236,11 @@ pub trait Iterator {
/// doing so, it keeps track of the current element. After [`None`] is
/// returned, `last()` will then return the last element it saw.
///
/// # Panics
///
/// This function might panic if the iterator has more than [`usize::MAX`]
/// elements.
///
/// # Examples
///
/// ```