From 36d879c25cf9ad4d451e5f1e13c73f16a79443ec Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Thu, 11 Jan 2018 22:01:33 +0100 Subject: [PATCH] Compat.IteratorSize and Compat.IteratorEltype (#451) --- README.md | 8 +++++++- src/Compat.jl | 9 +++++++++ test/runtests.jl | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 35441acbe..c5e7b8bd1 100644 --- a/README.md +++ b/README.md @@ -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]). @@ -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 diff --git a/src/Compat.jl b/src/Compat.jl index 6a10afa6c..694b46a69 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -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! diff --git a/test/runtests.jl b/test/runtests.jl index e56565aa0..8a4572cde 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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