Skip to content

Commit 86fbae1

Browse files
nategrafIan Goldberg
andauthored
Implement std::iter::Sum for Sum (#76)
to support dot products Co-authored-by: Ian Goldberg <[email protected]>
1 parent 18e9499 commit 86fbae1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/linear_relation/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ impl<T> Sum<T> {
108108
}
109109
}
110110

111+
impl<T> std::iter::Sum<T> for Sum<T> {
112+
/// Add a bunch of `T` to yield a `Sum<T>`
113+
fn sum<I>(iter: I) -> Self
114+
where
115+
I: Iterator<Item = T>,
116+
{
117+
Self(iter.collect())
118+
}
119+
}
120+
111121
/// Represents a sparse linear combination of scalars and group elements.
112122
///
113123
/// For example, it can represent an equation like:

0 commit comments

Comments
 (0)