Skip to content

Commit 5455078

Browse files
New GroupingMap::product_in
1 parent 8b4de1f commit 5455078

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/grouping_map.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ where
559559
where
560560
V: Mul<V, Output = V>,
561561
{
562-
self.reduce(|acc, _, val| acc * val)
562+
self.product_in(HashMap::new())
563563
}
564564
}
565565

@@ -786,4 +786,14 @@ where
786786
{
787787
self.reduce_in(|acc, _, val| acc + val, map)
788788
}
789+
790+
/// Apply [`product`](Self::product) with a provided empty map
791+
/// (`BTreeMap` or `HashMap` with any hasher).
792+
pub fn product_in<M>(self, map: M) -> M
793+
where
794+
V: Mul<V, Output = V>,
795+
M: Map<Key = K, Value = V>,
796+
{
797+
self.reduce_in(|acc, _, val| acc * val, map)
798+
}
789799
}

0 commit comments

Comments
 (0)