Skip to content

Commit 4b5d32d

Browse files
New GroupingMap::product_in
1 parent 2cfc868 commit 4b5d32d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/grouping_map.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ where
560560
where
561561
V: Mul<V, Output = V>,
562562
{
563-
self.reduce(|acc, _, val| acc * val)
563+
self.product_in(HashMap::new())
564564
}
565565
}
566566

@@ -769,4 +769,13 @@ where
769769
{
770770
self.reduce_in(|acc, _, val| acc + val, map)
771771
}
772+
773+
/// Apply [`product`](Self::product) with a provided map.
774+
pub fn product_in<M>(self, map: M) -> M
775+
where
776+
V: Mul<V, Output = V>,
777+
M: Map<Key = K, Value = V>,
778+
{
779+
self.reduce_in(|acc, _, val| acc * val, map)
780+
}
772781
}

0 commit comments

Comments
 (0)