Skip to content

Commit

Permalink
Optional: _copy function for copying empty array defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
gkappler committed Nov 4, 2020
1 parent adec265 commit 861527e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/get.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ function Base.get(parser::Either{<:Trie},
get(state.state)
end

_copy(x::Vector) = copy(x)
_copy(x::AbstractDict) = copy(x)
_copy(x::AbstractSet) = copy(x)
_copy(x) = x

function Base.get(parser::Optional,
sequence, till,
after, i, state)
if state === None()
parser.default
_copy(parser.default)
else
get(parser.parser,sequence, till, after, i, state)
end
Expand Down

0 comments on commit 861527e

Please sign in to comment.