-
Notifications
You must be signed in to change notification settings - Fork 188
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
Implementation of std::iter::{Product, Sum} #22
Conversation
The CI failure on 1.8 is expected -- we'll have to hold this until I'm ready to bump to num-bigint 0.2. I wonder, can this be implemented generically? Something like: impl<T> Sum<T> for BigUint
where BigUint: Add<T, Output=Self> { ... } Then it should work not just for iterators of If this works, I'd just write it directly, without the macro impls. |
I think adding such a generic impl might itself be a breaking change, as someone could have their own |
I really liked your suggestion, so I decided to make the two implementations generic. Two additional tests have been added to check against generic I want to ask you a thing about conditional compilation: is there a way to check against std features using |
Sadly, no. So many things would be easier if there were. |
This is relative to the [issue 4](rust-num#4). This is a very simple implementation, based on two macros. Maybe a more elegant solution is possible for these, feel free to suggest. Two tests for both `BigInt` and `BigUInt` have been added, one relative to the `Sum`, the other to the `Product`.
The succestion came from @cupiver, and it was simple and elegant. Now it should be possible to use `std::iter::{Sum, Product}` with everything that can be Add`-ed and `Mul`-tiplied _against_ `BigInt` and `BigUint`
348f82f
to
d6fa4ac
Compare
I rebased now that 0.2 has started, and fixed on issue with rust 1.15. Thanks for implementing this! bors r+ |
22: Implementation of std::iter::{Product, Sum} r=cuviper a=dodomorandi This PR is relative to the [issue 4](#4). This is a very simple implementation, based on two macros. Maybe a more elegant solution is possible for these, feel free to suggest. Two tests for both `BigInt` and `BigUInt` have been added, one relative to the `Sum`, the other to the `Product`.
Build succeeded |
This PR is relative to the issue 4. This is a
very simple implementation, based on two macros. Maybe a more elegant
solution is possible for these, feel free to suggest.
Two tests for both
BigInt
andBigUInt
have been added, one relativeto the
Sum
, the other to theProduct
.