Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/selectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const KeyInd = Union{AbstractString, Symbol}
const Inds = Union{AbstractVector{<:KeyInd}, NTuple{N, <:KeyInd} where {N},
AbstractVector{<:Integer}, NTuple{N, <:Integer} where {N}}

# Union of all valid single-argument selector index types
const SelectorIndex = Union{KeyInd, Integer, Colon, Inds}

function _getindex_array(x, key::Union{KeyInd, Integer})
values = List()
StructUtils.applyeach(x) do _, item
Expand Down Expand Up @@ -215,7 +218,7 @@ end
# convenience macro for defining high-level getindex/getproperty methods
macro selectors(T)
esc(quote
Base.getindex(x::$T, arg) = StructUtils.Selectors._getindex(x, arg)
Base.getindex(x::$T, arg::StructUtils.Selectors.SelectorIndex) = StructUtils.Selectors._getindex(x, arg)
Base.getindex(x::$T, ::Colon, arg) = StructUtils.Selectors._getindex(x, :, arg)
Base.getindex(x::$T, ::typeof(~), arg) = StructUtils.Selectors._getindex(x, ~, arg)
Base.getindex(x::$T, ::typeof(~), key, val) = StructUtils.Selectors._getindex(x, ~, key, val)
Expand Down
Loading