1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::{fbig::FBig, repr::Word, round::Round};
use core::{
iter::{Product, Sum},
ops::{Add, Mul},
};
impl<T, R: Round, const B: Word> Sum<T> for FBig<R, B>
where
Self: Add<T, Output = Self>,
{
fn sum<I: Iterator<Item = T>>(iter: I) -> Self {
iter.fold(FBig::ZERO, FBig::add)
}
}
impl<T, R: Round, const B: Word> Product<T> for FBig<R, B>
where
Self: Mul<T, Output = Self>,
{
fn product<I: Iterator<Item = T>>(iter: I) -> Self {
iter.fold(FBig::ONE, FBig::mul)
}
}