Skip to content

Commit

Permalink
use @eval
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin committed Mar 3, 2024
1 parent 66aa453 commit a0afef7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/optics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,12 @@ end
@inline modify(f, obj, optic::ComposedOptic) = _modifyc(f, obj, decompose(optic))

@inline _modifyc(f, obj, os::Tuple{}) = f(obj)
@inline _modifyc(f, obj, os::Tuple{Any}) = modify(f, obj, only(os))
@inline _modifyc(f, obj, os::Tuple) =
modify(obj, last(os)) do o1
_modifyc(f, o1, Base.front(os))
end
for N in [1:10; :(<: Any)]
@eval @inline _modifyc(f, obj, os::NTuple{$N,Any}) =
modify(obj, last(os)) do o1
_modifyc(f, o1, Base.front(os))
end
end

function delete(obj, optic::ComposedOptic)
modify(obj, optic.inner) do inner_obj
Expand Down

0 comments on commit a0afef7

Please sign in to comment.