Skip to content

Commit 5199a70

Browse files
committed
Remove unneeded saturating_add
1 parent 1cc8b6e commit 5199a70

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcore/str/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,10 @@ impl<'a> Iterator for Chars<'a> {
432432
#[inline]
433433
fn size_hint(&self) -> (usize, Option<usize>) {
434434
let (len, _) = self.iter.size_hint();
435-
(len.saturating_add(3) / 4, Some(len))
435+
// `(len + 3)` can't overflow, because we know that the `slice::Iter`
436+
// belongs to a slice in memory which has a maximum length of
437+
// `isize::MAX` (that's well below `usize::MAX`).
438+
((len + 3) / 4, Some(len))
436439
}
437440
}
438441

0 commit comments

Comments
 (0)