Skip to content

Commit

Permalink
keys(::Generator) pass-through
Browse files Browse the repository at this point in the history
Let keys pass through to allow lightweigth/lazy find* and arg* functions
  • Loading branch information
rapus95 committed May 14, 2020
1 parent 76d6a08 commit 79ca787
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ length(g::Generator) = length(g.iter)
size(g::Generator) = size(g.iter)
axes(g::Generator) = axes(g.iter)
ndims(g::Generator) = ndims(g.iter)
keys(g::Generator) = keys(g.iter)


## iterator traits
Expand Down
3 changes: 3 additions & 0 deletions test/functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ let gen = ((x,y) for x in 1:10, y in 1:10 if x % 2 == 0 && y % 2 == 0),
@test collect(gen) == collect(gen2)
end

# keys of a generator for find* and arg* (see #34678)
@test keys(x^2 for x in -1:0.5:1) == 1:5

# inference on vararg generator of a type (see #22907 comments)
let f(x) = collect(Base.Generator(=>, x, x))
@test @inferred(f((1,2))) == [1=>1, 2=>2]
Expand Down

0 comments on commit 79ca787

Please sign in to comment.