Skip to content

Commit 77f31ef

Browse files
committed
use checked_add for upper bound
1 parent 8cbff0b commit 77f31ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/iter/adapters/intersperse.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ where
200200
lo.saturating_sub(!started as usize)
201201
.saturating_add(next_is_some as usize)
202202
.saturating_add(lo),
203-
hi.map(|hi| {
203+
hi.and_then(|hi| {
204204
hi.saturating_sub(!started as usize)
205205
.saturating_add(next_is_some as usize)
206-
.saturating_add(hi)
206+
.checked_add(hi)
207207
}),
208208
)
209209
}

0 commit comments

Comments
 (0)