diff options
| author | bors <bors@rust-lang.org> | 2015-03-11 01:39:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-11 01:39:49 +0000 |
| commit | f899513a30165946a75ff7f515ab37a226e72172 (patch) | |
| tree | 89289546a702a8aae23e014c8a4cb0dd4619ccaf | |
| parent | cfea8ec41699e25c8fb524d625190f0cb860dc71 (diff) | |
| parent | 5199a7060bc0004d42a72ae6079493935777cf31 (diff) | |
| download | rust-f899513a30165946a75ff7f515ab37a226e72172.tar.gz rust-f899513a30165946a75ff7f515ab37a226e72172.zip | |
Auto merge of #23251 - tbu-:pr_rm_core_str_checked_add, r=alexcrichton
| -rw-r--r-- | src/libcore/str/mod.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 4e8a56fbefb..a5ade2ae2a5 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -442,7 +442,10 @@ impl<'a> Iterator for Chars<'a> { #[inline] fn size_hint(&self) -> (usize, Option<usize>) { let (len, _) = self.iter.size_hint(); - (len.saturating_add(3) / 4, Some(len)) + // `(len + 3)` can't overflow, because we know that the `slice::Iter` + // belongs to a slice in memory which has a maximum length of + // `isize::MAX` (that's well below `usize::MAX`). + ((len + 3) / 4, Some(len)) } } |
