-
Notifications
You must be signed in to change notification settings - Fork 115
implement Iter::chunk_by #2029
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
base: main
Are you sure you want to change the base?
implement Iter::chunk_by #2029
Conversation
Potential memory inefficiency with fixed buffer capacityCategory let initial_capacity = max(16, buffer.capacity())
buffer = Array::new(capacity=initial_capacity) Reasoning Missing edge case documentationCategory /// Groups consecutive elements of an iterator according to a discriminator function.
///
/// # Notes
/// - Empty iterators produce no chunks
/// - Single element iterators produce one chunk
/// - The discriminator function is called exactly once per element Reasoning Potential issue with early return in yield patternCategory if current_key is Some(old_key) {
guard yield_((old_key, buffer.iter())) is IterContinue else {
return IterEnd
}
}
IterContinue Reasoning |
Pull Request Test Coverage Report for Build 6575Details
💛 - Coveralls |
1223960
to
74c2ad5
Compare
I'm still not quite sure if the signature should be |
Iter was introduced as a data conversion layer between different collections. It was designed that compiler can optimize all the indirections so such conversion is almost free. It is less powerful than other iterators (e.g, lazy lists) where meomizations and zip is easy to implement. I would be happy to hear your thoughts |
As requested here