Add Itertools::{sum1, product1}#300
Merged
bors[bot] merged 1 commit intorust-itertools:masterfrom Oct 1, 2019
Merged
Conversation
421ac30 to
b18e66e
Compare
Contributor
Author
Uh, I don't know what travis is complaining about |
b18e66e to
f402283
Compare
Member
|
Thanks for the contribution! Could you rebase this on master? |
Like fold1, these return Option<T> Some(result) if the iter is nonempty, None otherwise. Allows differentiation between empty iterators and iterators that reduce to neutral elements
f402283 to
142659f
Compare
Contributor
Author
|
Rebased and reworded the first line of the doc comments for both methods as commands |
Member
|
bors r+ |
bors bot
added a commit
that referenced
this pull request
Oct 1, 2019
300: Add Itertools::{sum1, product1} r=jswrenn a=Emerentius
This implements `sum1` and `product1` consumers that are like `sum` and `product` except they produce an `Option<T>` with `Some` for nonempty iters and `None` otherwise, just like `fold1`.
That allows one to distinguish between an empty iter and iters that sum/multiply to their neutral element.
Co-authored-by: Emerentius <emerentius@arcor.de>
Contributor
Build succeeded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements
sum1andproduct1consumers that are likesumandproductexcept they produce anOption<T>withSomefor nonempty iters andNoneotherwise, just likefold1.That allows one to distinguish between an empty iter and iters that sum/multiply to their neutral element.