1
struct EnumerableIterable{T,S} <: Enumerable
2 47
    source::S
3
end
4

5
function query(source)
6 47
    IteratorInterfaceExtensions.isiterable(source) || error()
7 39
    typed_source = IteratorInterfaceExtensions.getiterator(source)
8
	T = eltype(typed_source)
9
    S = typeof(typed_source)
10

11 39
    source_enumerable = EnumerableIterable{T,S}(typed_source)
12

13 47
    return source_enumerable
14
end
15

16 0
Base.IteratorSize(::Type{EnumerableIterable{T,S}}) where {T,S} = haslength(S)
17

18 0
Base.eltype(::Type{EnumerableIterable{T,S}}) where {T,S} = T
19

20 39
Base.length(iter::EnumerableIterable{T,S}) where {T,S} = length(iter.source)
21

22
function Base.iterate(iter::EnumerableIterable{T,S}, state...) where {T,S}
23 47
    return iterate(iter.source, state...)
24
end
25

Read our documentation on viewing source code .

Loading