From 5199a7060bc0004d42a72ae6079493935777cf31 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Tue, 10 Mar 2015 14:18:24 +0100 Subject: [PATCH] Remove unneeded `saturating_add` --- src/libcore/str/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index b354116993c23..bb03994fc7a82 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -432,7 +432,10 @@ impl<'a> Iterator for Chars<'a> { #[inline] fn size_hint(&self) -> (usize, Option) { 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)) } }