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
27
28
29
30
31
use crate::U256;
use core::iter::{Product, Sum};
use core::ops::{Add, Mul};
impl Sum for U256 {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(U256::ZERO, Add::add)
}
}
impl Product for U256 {
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(U256::ONE, Mul::mul)
}
}
impl<'a> Sum<&'a U256> for U256 {
fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
iter.fold(U256::ZERO, Add::add)
}
}
impl<'a> Product<&'a U256> for U256 {
fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
iter.fold(U256::ONE, Mul::mul)
}
}