-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add new iterator function .chunk() #8376
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
@cmr: Based on @thestinger's comments on my PR regarding Skip (#8375), I'm modifying this one as well (since it also tried to peg |
.chunk() takes a uint and yields owned vectors of that length.
r? @cmr |
@cmr Regarding your comment about a test for |
@kballard I remain unconvinced |
I don't think this is how we should implement chunk - it's going to be far too inefficient. It shouldn't require an allocation for every iteration - this kind of thing doesn't belong as an adaptor in |
For example, this could yield an iterator of iterators. |
@thestinger An iterator of iterators is actually a good idea. I originally wanted to yield I'm going to close out this PR for the time being, I'll re-submit when I've implemented @thestinger's idea (not sure when though, as I'm going on vacation). |
I'm not 100% sure it will work, but I think it will. |
@thestinger Upon thinking about it, I think this may hit the same issue that trying to yield What it could do is buffer |
I am not sure if an iterator-that-yields-iterators can be done using the iterator trait and type system as it is today. As @kballard points out, it'd have to "give up" the underlying iterator temporarily, and the lifetime for which it would have to "give up" the underlying iterator is not known until you call |
[`chars_next_cmp`] Fix unescaped suggestion closes rust-lang#8373 changelog: [`chars_next_cmp`] Fix unescaped suggestion
.chunk() takes a uint and yields owned vectors of that length.
r? @thestinger