num-traits
num-traits copied to clipboard
Add `CheckedSum` and `CheckedProduct` traits
Closes https://github.com/rust-num/num-traits/issues/250
This adds CheckedSum and CheckedProduct traits as well as blanket implementations for them.
It also adds CheckedSumIter and CheckedProductIter traits and blanket implementations for those as that provides a much more ergonomic interface, allowing you to do:
asserteq!(Some(42), [40,2].iter().checked_sum());
asserteq!(Some(42), [40,2].into_iter().checked_sum());