Skip to content

Commit

Permalink
Make rest type-idempotent (JuliaLang#30871)
Browse files Browse the repository at this point in the history
  • Loading branch information
under-Peter authored and JeffBezanson committed Jan 29, 2019
1 parent 9a1cc63 commit 05acc22
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ julia> collect(Iterators.rest([1,2,3,4], 2))
```
"""
rest(itr,state) = Rest(itr,state)
rest(itr::Rest,state) = Rest(itr.itr,state)
rest(itr) = itr

"""
Expand Down
1 change: 1 addition & 0 deletions test/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ let s = "hello"
c = collect(rest(s, st))
@test c == ['e','l','l','o']
@test c isa Vector{Char}
@test rest(s, st) == rest(rest(s,4),st)
end

@test_throws MethodError collect(rest(countfrom(1), 5))
Expand Down

0 comments on commit 05acc22

Please sign in to comment.