Skip to content

Commit 9caa14b

Browse files
committed
Ensure filter_map! is specialized to functions
1 parent 45b302f commit 9caa14b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/base.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ end
225225
226226
Apply a function to each node in a tree.
227227
"""
228-
function foreach(f::Function, tree::AbstractNode; break_sharing::Val=Val(false))
228+
function foreach(
229+
f::F, tree::AbstractNode; break_sharing::Val=Val(false)
230+
) where {F<:Function}
229231
tree_mapreduce(
230232
t -> (@inline(f(t)); nothing), Returns(nothing), tree, Nothing; break_sharing
231233
)
@@ -258,12 +260,12 @@ end
258260
Equivalent to `filter_map`, but stores the results in a preallocated array.
259261
"""
260262
function filter_map!(
261-
filter_fnc::Function,
262-
map_fnc::Function,
263+
filter_fnc::F,
264+
map_fnc::G,
263265
destination::Vector{GT},
264266
tree::AbstractNode;
265267
break_sharing::Val=Val(false),
266-
) where {GT}
268+
) where {GT,F<:Function,G<:Function}
267269
pointer = Ref(0)
268270
foreach(tree; break_sharing) do t
269271
if @inline(filter_fnc(t))

0 commit comments

Comments
 (0)