diff --git a/src/AbstractIndices.jl b/src/AbstractIndices.jl index 08db8e6..27f5236 100644 --- a/src/AbstractIndices.jl +++ b/src/AbstractIndices.jl @@ -63,7 +63,7 @@ function Base.in(i, indices::AbstractIndices{I}) where I end # Match the default setting from Base - the majority of containers will know their size -Base.IteratorSize(indices::AbstractIndices) = Base.HasLength() +Base.IteratorSize(::AbstractIndices) = Base.HasLength() function Base.length(indices::AbstractIndices) if Base.IteratorSize(indices) isa Base.SizeUnknown diff --git a/src/Indices.jl b/src/Indices.jl index 6ae91ae..0025b5f 100644 --- a/src/Indices.jl +++ b/src/Indices.jl @@ -26,7 +26,13 @@ Indices{I}(iter) where {I} = Indices{I, typeof(iter)}(iter) # There is a corner end Base.in(i::I, inds::Indices{I}) where {I} = in(i, inds.inds) -Base.IteratorSize(i::Indices) = Base.IteratorSize(i.inds) +function Base.IteratorSize(i::Indices) + out = Base.IteratorSize(i.inds) + if out isa Base.HasShape + return Base.HasLength() + end + return out +end Base.length(i::Indices) = length(i.inds) # Specialize for `Vector` elements. Satisfy the tokenization and insertion interface