Skip to content

Commit

Permalink
use checked_add for upper bound
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jan 26, 2024
1 parent 8cbff0b commit 77f31ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/iter/adapters/intersperse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ where
lo.saturating_sub(!started as usize)
.saturating_add(next_is_some as usize)
.saturating_add(lo),
hi.map(|hi| {
hi.and_then(|hi| {
hi.saturating_sub(!started as usize)
.saturating_add(next_is_some as usize)
.saturating_add(hi)
.checked_add(hi)
}),
)
}
Expand Down

0 comments on commit 77f31ef

Please sign in to comment.