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

Require std::iter::Sum for Float

Open dbrgn opened this issue 6 years ago • 1 comments

Would it be possible to require std::iter::Sum for Float or maybe for Num?

Right now I cannot .sum() an iterator over T: Float.

dbrgn avatar Sep 07 '19 16:09 dbrgn

It would be a breaking change to add that requirement to existing traits.

You could use T: Float + Sum, or make your own meta-trait:

trait MyFloat: Float + Sum {}
impl<T: Float + Sum> MyFloat for T {}

cuviper avatar Sep 09 '19 17:09 cuviper