Skip to content

Commit

Permalink
Compat.IteratorSize and Compat.IteratorEltype (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Jan 11, 2018
1 parent 3c1d4fc commit 36d879c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ Currently, the `@compat` macro supports the following syntaxes:

* `unshift!` and `shift!` are now `pushfirst!` and `popfirst!` ([#25100]).

* `Base.IteratorSize` and `Base.IteratorEltype` are available as
`Compat.IteratorSize` and `Compat.IteratorEltype` ([#25402]).

* `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]).

* `ipermute!` is now `invpermute!` ([#25168]).
Expand Down Expand Up @@ -428,13 +431,16 @@ includes this fix. Find the minimum version from there.
[#24657]: https://github.com/JuliaLang/julia/issues/24657
[#24714]: https://github.com/JuliaLang/julia/issues/24714
[#24785]: https://github.com/JuliaLang/julia/issues/24785
[#24808]: https://github.com/JuliaLang/julia/issues/24808
[#25012]: https://github.com/JuliaLang/julia/issues/25012
[#25021]: https://github.com/JuliaLang/julia/issues/25021
[#25056]: https://github.com/JuliaLang/julia/issues/25056
[#25057]: https://github.com/JuliaLang/julia/issues/25057
[#25100]: https://github.com/JuliaLang/julia/issues/25100
[#25102]: https://github.com/JuliaLang/julia/issues/25102
[#25113]: https://github.com/JuliaLang/julia/issues/25113
[#25162]: https://github.com/JuliaLang/julia/issues/25162
[#25165]: https://github.com/JuliaLang/julia/issues/25165
[#25168]: https://github.com/JuliaLang/julia/issues/25168
[#25113]: https://github.com/JuliaLang/julia/issues/25113
[#25227]: https://github.com/JuliaLang/julia/issues/25227
[#25402]: https://github.com/JuliaLang/julia/issues/25402
9 changes: 9 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,15 @@ end
export pushfirst!, popfirst!
end

# 0.7.0-DEV.3309
@static if VERSION < v"0.7.0-DEV.3309"
const IteratorSize = Base.iteratorsize
const IteratorEltype = Base.iteratoreltype
else
const IteratorSize = Base.IteratorSize
const IteratorEltype = Base.IteratorEltype
end

# 0.7.0-DEV.3173
@static if !isdefined(Base, :invpermute!)
const invpermute! = ipermute!
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,12 @@ let coolvec = [1,2,3]
@test popfirst!(coolvec) == 0
end

# 0.7.0-DEV.3309
let v = [1, 2, 3]
@test Compat.IteratorSize(v) == Base.HasShape()
@test Compat.IteratorEltype(v) == Base.HasEltype()
end

# 0.7.0-DEV.3057
let A = [0, 0, 0], B = [1, 2, 3]
@test copyto!(A, B) === A == B
Expand Down

0 comments on commit 36d879c

Please sign in to comment.