Closures being passed as args multiple times?


I’m trying to implement a sort of ‘select’ function for a quad tree implementation similar to what you’d find in SQL. It takes a predicate (Fn I believe covers both closures and functions?) and what it’s supposed to do is iterate through a vector of items it has and evaluate the predicate for each, then the ‘select’ function is supposed to recursively call itself on an array of child nodes and evaluate the predicate on each of them.

The problem is that closures cannot copy nor clone. How would I pass a closure as an argument multiple times?


You’d pass a reference to the closure.


… there goes my 4am logic again. I should ask during the day I think.