Closed eutampieri closed 4 years ago
I've just added this to fraction/mod.rs and it works
impl<T: Clone + Integer> Sum for GenericFraction<T> {
fn sum<I: Iterator<Item=Self>>(iter: I) -> Self {
iter.fold(GenericFraction::<T>::neg_zero(), Add::add)
}
}
Hi @eutampieri, thank you for the idea. Fair enough.
I think that would also make sense to add Product implementation. Would you like to contribute a PR? Ideally that would be an implementation of both traits for Fraction and Decimal and some test coverage for them. If you don't have time, I'll prepare a patch for the next minor release myself, no pressure :)
It would be useful if you implemented the Sum trait in order to use the .sum() on an iterator over a vec of fractions. At the moment it fails with the following error: