Skip to content

Commit 1cabcb3

Browse files
authored
Merge pull request #1 from davidanthoff/iteratorsize2
Add iteratorsize2
2 parents a5c9f98 + 75af198 commit 1cabcb3

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/IteratorTraits.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__precompile__(true)
22
module IteratorTraits
33

4-
export getiterator, isiterable
4+
export getiterator, isiterable, iteratorsize2
55

66
isiterable(x::T) where {T} = method_exists(start, Tuple{T})
77

@@ -12,4 +12,9 @@ function getiterator(x)
1212
return x
1313
end
1414

15+
struct HasLengthAfterStart <: Base.IteratorSize end
16+
17+
iteratorsize2(x) = iteratorsize2(typeof(x))
18+
iteratorsize2(::Type{T}) where {T} = Base.iteratorsize(T)
19+
1520
end # module

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ end
1313

1414
@test [1,2,3] == getiterator([1,2,3])
1515

16+
@test iteratorsize2([1,2,3]) == Base.HasShape()
17+
1618
end

0 commit comments

Comments
 (0)