-
Notifications
You must be signed in to change notification settings - Fork 13.3k
chunk
like Iterators should panic on overflow
#51254
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
Comments
chunk
like Iterators must panic on overflowchunk
like Iterators should panic on overflow
https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.nth
|
I agree with what you said. The thing that bothered me is the fact that if it is not possible to access the chunk that produced an overflow with one fn nth(&mut self, n: usize) -> Option<Self::Item> {
let (start, overflow) = n.overflowing_mul(self.chunk_size);
if start >= self.v.len() || overflow {
// ... But it is not possible because if the multiplication has overflowed so it is likely that the accessed pointer is non addressable and so So we can close this. Thank you for your time. |
Closing as suggested. |
Currently the
Chunks
,ChunksMut
,ExactChunks
andExactChunksMut
adapters does returnNone
if an overflow occur in theIterator::nth
method.I think this is not a good thing to have a silent "error", we must be consistent with other iterator adapters like
enumerate
and panic if an overflow is detected.This has been talked in the tracking issue of the
ExactChunks/Mut
iterators adapters.The text was updated successfully, but these errors were encountered: