-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add/modify iterator size_hint()s #8604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When PR #8582 lands, |
@@ -1504,6 +1522,9 @@ impl<A: Add<A, A> + Ord + Clone> Iterator<A> for Range<A> { | |||
None | |||
} | |||
} | |||
|
|||
// FIXME: Implement size_hint() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think tidy.py will yell about this, need to make an issue and add the number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh damn, so it does. I didn't realize.
Add size_hint() to a few Iterators that were missing it. Update a couple of existing size_hint()s to use checked_add() instead of saturating_add() for the upper bound.
if self.v.len() == 0 { | ||
(0, Some(0)) | ||
} else { | ||
let (n, rem) = self.v.len().div_rem(&self.size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this handle size == 0 properly? or do we not wind up in this iterator in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chunk_iter()
has assert!(size != 0)
.
Implement `size_hint()` on the new std::vec Iterators. Add or update `size_hint()` on std::iterator Iterators where appropriate. r? @thestinger
…r=Alexendoo Fix redundant_allocation warning for Rc<Box<str>> changelog: [`redundant_allocation`] Fixes rust-lang#8604 Fixes false positives where a fat pointer with `str` type was made thin by another allocation, but that thinning allocation was marked as redundant
Implement
size_hint()
on the new std::vec Iterators.Add or update
size_hint()
on std::iterator Iterators where appropriate.r? @thestinger