We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cfea8ec + 5199a70 commit f899513Copy full SHA for f899513
src/libcore/str/mod.rs
@@ -442,7 +442,10 @@ impl<'a> Iterator for Chars<'a> {
442
#[inline]
443
fn size_hint(&self) -> (usize, Option<usize>) {
444
let (len, _) = self.iter.size_hint();
445
- (len.saturating_add(3) / 4, Some(len))
+ // `(len + 3)` can't overflow, because we know that the `slice::Iter`
446
+ // belongs to a slice in memory which has a maximum length of
447
+ // `isize::MAX` (that's well below `usize::MAX`).
448
+ ((len + 3) / 4, Some(len))
449
}
450
451
0 commit comments