Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/adaptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ where
let (combined_lower, combined_upper) =
size_hint::mul_scalar(size_hint::min(curr_hint, next_hint), 2);
let lower = if curr_lower > next_lower {
combined_lower + 1
combined_lower.saturating_add(1)
} else {
combined_lower
};
Expand Down
8 changes: 8 additions & 0 deletions tests/test_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ fn interleave_shortest() {
let i1 = ::std::iter::repeat(1);
let it = v0.into_iter().interleave_shortest(i1);
assert_eq!(it.size_hint(), (6, Some(6)));

// Issue #1068: combined lower bound used to overflow when both halves
// reported saturating lower bounds, panicking in debug builds.
let i0 = ::std::iter::repeat(0).take(usize::MAX);
let i1 = ::std::iter::repeat(1);
let it = i0.interleave_shortest(i1);
let (lower, _) = it.size_hint();
assert_eq!(lower, usize::MAX);
}

#[test]
Expand Down