Skip to content
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

Do not sum options #745

Merged
merged 1 commit into from
Sep 6, 2023
Merged

Conversation

Philippe-Cholet
Copy link
Member

@Philippe-Cholet Philippe-Cholet commented Sep 6, 2023

A mistake on my part, discovered in time as code is still commented out. Note that it passed tests.
It only returns None if the iterator yields None. But it would overflow whenever an addition does.

Do not product options either, as multiplications could overflow the same way. That's how I found out.

I guess checked_sum and checked_product methods would be nice.
EDIT: Would you be interested? Related: rust-lang/rust#95485

A mistake on my part.
It only returns None if the iterator yields None. But it would overflow when an addition does.
I guess a `checked_sum` method would be nice.

PS: Do not product options either, as multiplications could overflow the same way. That's how I found out.
@phimuemue
Copy link
Member

Nicely spotted @Philippe-Cholet.

Possibly indicates that we should really include the overflowing parts in tests.

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 6, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

  • bors build finished

@bors bors bot merged commit 557cb89 into rust-itertools:master Sep 6, 2023
@Philippe-Cholet
Copy link
Member Author

I missed the "Panics" section of the sum method. So that's more embarassing than nicely spotted.

@Philippe-Cholet Philippe-Cholet deleted the no-sum-options branch September 6, 2023 08:10
@jswrenn jswrenn added this to the next milestone Nov 14, 2023
@jswrenn jswrenn mentioned this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants