Skip to content

Commit c584c71

Browse files
committed
Remove redundant match_result_product() function
1 parent 4f3ef75 commit c584c71

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

lib/examples/custom_match.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ impl Grounded for TestDict {
3636
impl CustomMatch for TestDict {
3737
fn match_(&self, other: &Atom) -> MatchResultIter {
3838
if let Some(other) = other.as_gnd::<TestDict>() {
39-
other.0.iter().map(|(ko, vo)| {
39+
Box::new(other.0.iter().map(|(ko, vo)| {
4040
self.0.iter().map(|(k, v)| {
4141
match_atoms(&Atom::expr(vec![k.clone(), v.clone()]), &Atom::expr(vec![ko.clone(), vo.clone()]))
4242
}).fold(Box::new(std::iter::empty()) as MatchResultIter, |acc, i| {
4343
Box::new(acc.chain(i))
44-
})
45-
}).fold(Box::new(std::iter::once(Bindings::new())),
46-
|acc, i| { matcher::match_result_product(acc, i) })
44+
}).collect::<BindingsSet>()
45+
}).fold(BindingsSet::single(),
46+
|acc, i| { acc.merge(&i) })
47+
.into_iter())
4748
} else {
4849
Box::new(std::iter::empty())
4950
}

lib/src/atom/matcher.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1134,16 +1134,6 @@ fn match_atoms_recursively(left: &Atom, right: &Atom) -> BindingsSet {
11341134
res
11351135
}
11361136

1137-
//TODO: This function is redundant, as the functionality is subsumed by BindingsSet::merge
1138-
/// Merges each bindings from `prev` iter to each bindings from `next`
1139-
/// iter. The result is an iter over successfully merged bindings.
1140-
pub fn match_result_product(prev: MatchResultIter, next: MatchResultIter) -> MatchResultIter {
1141-
let next: BindingsSet = next.collect();
1142-
let prev: BindingsSet = prev.collect();
1143-
log::trace!("match_result_product_iter, next: {:?}", next);
1144-
Box::new(prev.merge(&next).into_iter())
1145-
}
1146-
11471137
/// Applies bindings to atom and return it (see [apply_bindings_to_atom_mut]).
11481138
#[inline]
11491139
pub fn apply_bindings_to_atom_move(mut atom: Atom, bindings: &Bindings) -> Atom {

0 commit comments

Comments
 (0)