num-traits icon indicating copy to clipboard operation
num-traits copied to clipboard

Add `CheckedSum` and `CheckedProduct` traits

Open wainwrightmark opened this issue 3 years ago • 0 comments

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());

wainwrightmark avatar Nov 02 '22 17:11 wainwrightmark