Closed
Description
I’m creating this issue in order to better document the bug in std
that #87974 fixes once it’s merged.
fn this_should_hold_for_non_buggy_iterators(i: impl Iterator) {
let (lower_hint, count) = dbg!(i.size_hint().0, i.count());
assert!(lower_hint <= count)
}
fn main() {
this_should_hold_for_non_buggy_iterators([()].splitn(0, |_| false));
// [src/main.rs:3] i.size_hint().0 = 1
// [src/main.rs:3] i.count() = 0
// thread 'main' panicked at 'assertion failed: lower_hint <= count', src/main.rs:4:5
}
@rustbot label T-libs, A-slice, A-iterators