about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-09-17 14:56:46 +1000
committerGitHub <noreply@github.com>2025-09-17 14:56:46 +1000
commitcefd9325201d21388200d18d090016fbae5840e4 (patch)
tree0e58af545c1ee448d21bdc0e16d138ff8e0bac68 /compiler/rustc_trait_selection/src
parent79f8acb45bda881587b23be9c33538363d777555 (diff)
parentc89b6a955c9e16c7c96714cea7945945caadcc79 (diff)
downloadrust-cefd9325201d21388200d18d090016fbae5840e4.tar.gz
rust-cefd9325201d21388200d18d090016fbae5840e4.zip
Rollup merge of #146410 - hkBst:repeat-1, r=jhpratt
Iterator repeat: no infinite loop for `last` and `count`

This removes two cases of infinite looping from [`Repeat`](https://doc.rust-lang.org/nightly/std/iter/struct.Repeat.html):
- [`last`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.last): By viewing the iterator as returning None after [omega](https://en.wikipedia.org/wiki/Ordinal_number) calls to `next`, this method can simply return the repeated element.

- [`count`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.count): From its docs: """The method does no guarding against overflows, so counting elements of an iterator with more than [usize::MAX](https://doc.rust-lang.org/nightly/std/primitive.usize.html#associatedconstant.MAX) elements either produces the wrong result or panics. If overflow checks are enabled, a panic is guaranteed.""", so a panic'ing impl is allowed by the docs, and is more honest than an infinite loop.
Diffstat (limited to 'compiler/rustc_trait_selection/src')
0 files changed, 0 insertions, 0 deletions