Skip to content

Commit 79ca787

Browse files
committed
keys(::Generator) pass-through
Let keys pass through to allow lightweigth/lazy find* and arg* functions
1 parent 76d6a08 commit 79ca787

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

base/generator.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ length(g::Generator) = length(g.iter)
5151
size(g::Generator) = size(g.iter)
5252
axes(g::Generator) = axes(g.iter)
5353
ndims(g::Generator) = ndims(g.iter)
54+
keys(g::Generator) = keys(g.iter)
5455

5556

5657
## iterator traits

test/functional.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ let gen = ((x,y) for x in 1:10, y in 1:10 if x % 2 == 0 && y % 2 == 0),
134134
@test collect(gen) == collect(gen2)
135135
end
136136

137+
# keys of a generator for find* and arg* (see #34678)
138+
@test keys(x^2 for x in -1:0.5:1) == 1:5
139+
137140
# inference on vararg generator of a type (see #22907 comments)
138141
let f(x) = collect(Base.Generator(=>, x, x))
139142
@test @inferred(f((1,2))) == [1=>1, 2=>2]

0 commit comments

Comments
 (0)